Display Random Author with Details in Sidebar

Your best option is to get a random post author which is a user ID so here is a function to do just that: function get_random_author_wpa91320(){ global $wpdb; $id = $wpdb->get_var(” SELECT post_author FROM $wpdb->posts WHERE post_type=”post” AND post_status=”publish” ORDER BY RAND() LIMIT 1 “); return $id; } And once you have that function in … Read more

Best way of making multiple sidebars

Defining new sidebar with in your functions.php <?php if ( function_exists(‘register_sidebar’) ) { register_sidebar(array( ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ )); }?> Once these are functions are defined, you will notice the extra sidebar appear in the WordPress Dashboard under the Appearance > Widgets option. … Read more

how do I get_sidebar into a varaible?

You probably need to use output buffering, if I understand your question correctly. Try something like this: ob_start(); dynamic_sidebar(‘sidebar-id’); $sidebar = ob_get_contents(); ob_end_clean(); That will put the output of the sidebar into the variable $sidebar, which you can then process and return from your filter on the page content.

How to edit contents of dynamic_sidebar()?

The contents of dynamic_sidebar are pulled from the widgets associated with this “Sidebar” aka “Widget Area” in wp-admin, as @s_ha_dum answered. There is no template file for the sidebar itself. Visit /wp-admin/widgets.php under Appearance -> Widgets and find the widget area titled homepage-infobox. You be able to add/remove widgets and possibly make changes to the … Read more

Retrieve each widget separately from a sidebar

I am taking the core of the question to be: “… I’m not able to retrieve the widget class name” You will need to check the global variable $wp_registered_widgets to fill in the missing information. This proof-of-concept code should give you the idea. The code assumes a sidebar named sidebar-1. You will have to adjust … Read more

Sharing Dynamic Sidebars across Multisite Blogs

Unfortunately, the switch_to_blog() method isn’t going to work for this purpose. switch_to_blog() is really only a partial switch – it makes some modifications to $wpdb that help with database queries. But it’s not a complete switch in the way you might imagine. In particular, dynamic_sidebar() depends on global called $wp_registered_sidebars. This global is populated by … Read more

Get number of widgets in sidebar

After some research and based on the answer from Eugene Manuilov I made a function that adds custom classes to widgets in a specific sidebar (‘sidebar-bottom’ in my case) based on the number of widgets set in that sidebar. This will suit perfectly in horizontal sidebars and themes based on twitter bootstrap that need spanX … Read more