Get a sidebar at the top of the page

This method works from your child themes functions.php file. Change the hook to a different position: //functions.php function wpsites_register_widget() { register_sidebar( array( ‘name’ => ‘After Header Widget’, ‘id’ => ‘after-header’, ‘before_widget’ => ‘<div>’, ‘after_widget’ => ‘</div>’, ) ); } add_action( ‘widgets_init’, ‘wpsites_register_widget’ ); add_filter( ‘loop_start’, ‘after_header_widget’, 25 ); function after_header_widget() { if ( is_active_sidebar( ‘after-header’ … Read more

Category specific months list in sidebar.php

you can use getarchives_where filter to get archives by category add_filter( ‘getarchives_where’, ‘my_archives_filter_function’, 10, 2 ); // your filter function replace YOUR CATEGORY ID with category term id e.g(3) function my_archives_filter_function($where) { global $wpdb; $where .” AND $wpdb->posts.ID IN (SELECT $wpdb->posts.ID FROM $wpdb->posts INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id … Read more

How do I hook a sidebar via add_action?

Explanation There’s the global array $wp_filters. This array stores some sub arrays. One for each priority. Each sub array then contains an array for each callback added. And the keys for those sub-sub arrays are the attached functions. Example If you do the following, somewhere in your code (preferable after the init hook): echo ‘<pre>’; … Read more

bloginfo(‘stylesheet_directory’) vs. get_stylesheet_directory_uri() and include(‘file.php’) vs. get_template_part()

get_stylesheet_directory_uri() returns a value, it doesn’t print anything. So you have to use: echo get_stylesheet_directory_uri(); get_template_part() is just a wrapper for locate_template(). But the latter has one advantage: It returns the path of the file it has found. Try the following: $path = locate_template( ‘sidebar-front.php’, TRUE ); echo $path;

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