Calling widget via function in themes files (hard code)

Using the_widget() is the correct way to “hard code” an arbitrary Widget in a template file: <?php the_widget( ‘foobar_widget’, $instance, $args ); ?> Since the_widget() simply returns if ‘foobar_widget’ is not a registered Widget, it is functionally equivalent to using an if ( function_exists( $function ) ) conditional. You could look in core to see … Read more

Creating a custom menu/widget area

I’m going to assume you’re using Twenty Eleven theme, or another theme that supports child themes. If you’re using a custom theme, then you can just edit the existing Functions.php and add your additional functionality there, and then edit the existing Style.css. However, if your situation is different, please post back, and I’ll update to … Read more

Add description to custom text widget and display the 5 recent post titles

You are not passing your description correctly. Really, you aren’t passing it at all. public function __construct() { parent::WP_Widget(false, $name=”Kevins Textbox”); array(‘description’ => __(‘A text widget created by Kevin Ullyott for practice in creating widgets’) ); } That ‘description’ line is creating an array but you aren’t doing anything with it. It is just floating … Read more

jQuery UI inside widget on admin page

Ok, so, for some reason I can’t comprehend, the answer is that the div element containing the tabs should have a class and not an id for jQuery UI to work properly, as such: <div class=”mytabs”> and jQuery(document).ready(function($) { $(“.mytabs”).tabs(); }); Just for the record, the way I enqued the scripts is: add_action( ‘admin_enqueue_scripts’, ‘load_my_admin_js’ … Read more

Wrap all default widget into div tag

In the register_sidebar() call in functions.php. Look for before_widget and after_widget and modify as appropriate. The code below is the default usage. ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’,

Display single widget

You can force a particular widget that you have modified on the backend to show up if you can identify is sufficiently. I consider that very prone to error. You should be able to get the_widget to work if you pass enough detail through the (up to) three parameters– like this: the_widget(‘home_widget’,array(‘markup’ => ‘Yay’)); But … Read more