WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using this code to display a author box after my blog posts. The issue that I'm having is that it is showing up on all custom post types as well which I don't want. What I need is for it to show up on posts that are in the category of 'blog'. Anyone have any suggestions on what I need to do to accomplish this?

Thanks in advance!

// creates the author bio after posts
function get_author_bio ($content=''){
global $post;

$html="<div class='clearfix' id='about_author'>\n";
$html.="<img width='80' height='80' class='avatar' src='http://www.gravatar.com/avatar.php?gravatar_id=".md5(get_the_author_email()). "&default=".urlencode($GLOBALS['defaultgravatar'])."&size=80&r=PG' alt='PG'/>\n";
$html.="<div class='author_text'>\n";
$html.="<h4>Author: <span>".$post_author_name."</span></h4>\n";
$html.= $post_author_description."\n";
$html.="<div class='clear'></div>\n";
$content .= $html;

return $content;

add_filter('the_content', 'get_author_bio');
share|improve this question
up vote 1 down vote accepted

Use get_post_type() to check the correct post type and in_category( 'blog' ) to check the category:

function get_author_bio ($content=''){

    if ( 'post' !== get_post_type() or ! in_category( 'blog' ) )
        return $content;
share|improve this answer
When I use this, I get an error :Parse error: syntax error, unexpected '=' in /home/graphica/public_html/wp-content/themes/graphical-force/functions.php on line 251 – graphical_force Jun 15 '13 at 17:28
@graphical_force Yeah, there was one = too much. See my update. :) – toscho Jun 15 '13 at 17:32
That worked! Thanks! – graphical_force Jun 15 '13 at 17:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.