Sidebar random author spotlight

You can cut a lot of steps out of this if you use get_users() instead of your custom SQL query. You can then select a random user out of that array using array_rand() (native PHP function, not a wordpress function) and it will return the key you should be using. Here’s an example: $users = … Read more

Custom sidebar not showing in the dashboard

Register sidebar. add_action( ‘widgets_init’, ‘wpse_123456_widgets_init’ ); function wpse_123456_widgets_init() { $args = array( ‘name’ => __( ‘Sidebar name’, ‘theme_text_domain’ ), ‘id’ => ‘unique-sidebar-id’, ‘description’ => ”, ‘class’ => ”, ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ ); if ( function_exists (‘register_sidebar’)) { register_sidebar( $args ); } } … Read more

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

Add featured image to sidebar [closed]

Instead of modifying the sidebar or templates itself, why not create a plugin with a widget that does just what you need. This way you don’t hard code and keeps thing dynamic. This will also allow you to move the widget around at will you keep your templates clean, simple and maintainable do it the … 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

Display comment form of specific page in sidebar

Don’t build your own form and don’t modify comments.php – it’s purpose is little bit different and I don’t think you should include it inside sidebar. Just put comment_form function call in your sidebar template. It takes 2 parameters: args and post_id. So you can do it like this: $args = array( … // your … 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’ ); }

techhipbettruvabetnorabahisbahis forumutaraftarium24edusedueduedusedueduseduseduseduedu