Add div class to only one widget

You have two possible solutions. 1. The widget_display_callback filter hook This filter hook parameters allows you to target easily the widget instance and override it’s arguments. A possible approach would be: Inside the filter callback, modify the arguments for that instance, display it and then return false to prevent it from being displayed again the … Read more

register_sidebar notice [closed]

Find file where is register_sidebar ( must be on theme folder or plugins ) add ID to sidebar register_sidebar( array( ‘name’ => __( ‘Main Sidebar’, ‘theme-slug’ ), ‘id’ => ‘change_me’, // Add only this line ‘description’ => __( ‘Widgets in this area will be shown on all posts and pages.’, ‘theme-slug’ ), ‘before_widget’ => ‘<li … Read more

Get custom side bar on custom post archive page

get_sidebar($name) will load a template sidebar-{$name}.php. If sidebar-{$name}.php does not exist, then it will fallback to loading sidebar.php. to have your specific sidebar, you can create a file sidebar-bibliography_sidebar.php in your theme with this code : <?php if ( is_active_sidebar( ‘bibliography_sidebar’ ) ) { dynamic_sidebar( ‘bibliography_sidebar’ ); }

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

How to register_sidebar() without messing up the order?

function self_deprecating_sidebar_registration(){ register_sidebar( /* Your arguments here */ ); } add_action( ‘wp_loaded’, ‘self_deprecating_sidebar_registration’ ); Most themes will register the sidebar in their functions file, which is included before init but after plugins are loaded. Hooking onto wp_loaded should guarantee that your sidebar is registered after the theme’s.

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

How to wrap the widget content with a div or get the widget title outside?

this is the solution to wrap the content after the title like this ‘before_widget’ => ‘<li>’, ‘after_widget’ => ‘</div></li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2><div class=”widgetcontent”>’ ); ?> the important markup is the <div class=”widgetcontent>” in the after_title, and the closing </div> in the after_widget, this will result in this html markup: <ul> <li> … Read more