dynamic_sidebar not rendering sidebar

You should add the name and id parameters to your register_sidebar() argument array: ‘name’=>’Sidebar Name’, ‘id’=>’sidebar-slug’, Like such: register_sidebar(array( ‘name’=>’Sidebar Name’, ‘id’=>’sidebar-slug’, ‘before_widget’ => ‘<section>’, ‘after_widget’ => ‘</section>’, ‘before_title’ => ‘<h3>’, ‘after_title’ => ‘</h3>’, )); Then call the id of the Sidebar in your dynamic_sidebar() call: if ( ! dynamic_sidebar( ‘sidebar-slug’ ) ) { } … Read more

Register multiple sidebars

You just need to use the alternate syntax for foreach. From the php manual: The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. … Read more

is_home() and is_single() Not Working as Expected with Custom Post Types?

If I understand your question correctly then use are asking why is_home() is false when you are viewing the URL /tools/example-tool/? If I understand your question the answer is simply that is_home() is not true for Custom Post Types. Actually is_home() should never be true except for 1.) when on the home page list of … Read more

Different widgets on different page templates?

You will need to create more sidebars in your functions.php file and then edit the page templates to call the sidebar you want. Adding sidebars Go in to your functions.php file. You should see some sidebars already being registered. The code will look something like this: //Adds default sidebar if ( function_exists(‘register_sidebar’) ) register_sidebar(); To … Read more

Including Custom Post Types in “Recent Posts” Widget

You’ll have to edit the code for the Recent Posts widget or create your own version based on the default. The code is in the wp-includes/default-widgets.php file around line 513. But since you should never make modifications to core, my recommendation would be to copy the code to create your own My Custom Recent Posts … Read more

Get sidebar parameters (before_widget, before_title, etc.) from within a widget

The parameters are given (as an array) as the first argument provided to the widget method. The second argument, $instance, holds the options for that particular instance of the widget. My usual set up is: function widget($args, $instance){ //Extract the widget-sidebar parameters from array extract($args, EXTR_SKIP); echo $before_widget; echo $before_title; //Display title as stored in … Read more