Return to Snippet

Revision: 32579
at September 29, 2010 08:01 by jschultz76


Initial Code
<?php

/* the following goes into the functions.php file */
if (function_exists('register_sidebar')) {

	register_sidebar(array(
		'name' => 'My Custom Widget',
		'id'   => 'my_custom_widget',
		'description'   => 'Widget area for home page center left column',
		'before_widget' => '<div id="widget-id" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2>',
		'after_title'   => '</h2>'
	));

}

?>

<?php

/* this goes into your template file where you want the widget to appear */

?>

<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('my_custom_widget')) : else : ?>
	<div class="widget">
		<h2>Widget Ready</h2>
		<p>This my_custom_widget is widget ready! Add one in the admin panel.</p>
	</div>
<?php endif; ?>

Initial URL

                                

Initial Description
The code below is used to create a custom widget area in a WP template

Initial Title
Custom Widget in WordPress

Initial Tags

                                

Initial Language
PHP