WordPress.org

Ready to get started?Download WordPress

Forums

How to display different sidebar content based on the author of a post? (5 posts)

  1. samell1
    Member
    Posted 2 years ago #

    Hey all,

    We're in the process of redoing our site's sidebar. We'd like for the author bio's to appear in the sidebar of each post, but as we run a site with more than one writer, this would need to vary based on who the author was. The conditional tag is_author () only seems to apply to an author's archive page. Can anyone think of a creative way around this? We're also having trouble with the Widget Logic plugin affecting our theme's images (bizaree?), so if there's a way to do it without Widget Logic, I'm all ears.. Thanks so much!

    URL: http://www.realgeekstech.com
    Theme: Mystique, V 2.4.3

  2. alanft
    Member
    Posted 2 years ago #

    i haven't found a widget that shows the author bio, but I haven't looked in ages and there's probably one out there now. You'd then set this up to show on

    is_single()

    i suspect - if you persist with Widget Logic.

    FWIW, here's the widget I wrote years ago to do it though:

    function blog_author_bio($args)
    {	global $wp_query, $userdata;
    	extract($args);
    	$author_obj = ($wp_query->post); $author_obj= get_userdata($author_obj->post_author);
    	$title=($author_obj->user_nicename);
    	if ($author_obj->user_firstname)
    		$title=($author_obj->user_firstname)." ".($author_obj->user_lastname);
    
    	echo $before_widget . $before_title . $title . $after_title;
    
    	if ($author_obj->user_description)
    		echo substr(apply_filters('category_description', $author_obj->user_description),3);
    	else
    		echo "<p>No biography available.</p>";
    
    	if ($userdata->ID == $author_obj->ID)
    	{	?><p><a href="/wordpress/wp-admin/profile.php">Edit your Biographical Info</a></p><? }
    
    	echo $after_widget;
    }

    which is registered with

    register_sidebar_widget('Author Bio','blog_author_bio');

  3. MelvinSoftware
    Member
    Posted 2 years ago #

    You might try this plugin, see if you can do what you want with it:

  4. samell1
    Member
    Posted 2 years ago #

    You might try this plugin, see if you can do what you want with it:

    Oops, I think you forgot the link!

  5. MelvinSoftware
    Member
    Posted 2 years ago #

    Sorry about that, had it in there but forgot to close the tag.

    This is a plugin that I programmed specifically to be able to put dynamic content on the sidebar, based on content input on the Post creation page. You might be able to get it to do what you want.

    Here you go: Based On Post

Topic Closed

This topic has been closed to new replies.

About this Topic