Can´t make work a conditional: if(is_author('xx')){ ?>

Discussion in 'Bug Reports' started by cloferba, May 27, 2012.

  1. cloferba Member

    I´m trying to insert adsense code depending on the user who created the entry...but for any reason, with the bridge enabled, the conditional doesn´t work.

    Please check this:
    if(is_author('author1')){ ?>
    <?php } elseif(is_author('Author2')){ ?>
    <?php } elseif(is_author('Author3')){ ?>
    <?php } ?>
    What am I doing wrong?
  2. Jamie Administrator

    You shouldn't use is_author if at all possible. In what context are you putting this code? Where exactly is it going (file etc)?
  3. cloferba Member

    I use this code on Single.php and the code I want to show are Google ads depending on the user who created the entry.
  4. Jamie Administrator

    My suggestion would be to find the part in your current template that actually displays the author's name, take that variable and use that for your conditional. That way you know it's sure to work.
  5. cloferba Member

    and how can I do that? give me a bit of help :(
  6. Jamie Administrator

    It depends on how your template is set up and the context it's in, but you could, for example, try using
    to get the name of the author
  7. cloferba Member

    I´m using a basic wordpress template but I don´t know how to put the code
  8. Jamie Administrator

    I can't possibly guess at it without seeing the template. If you want me to have a look properly then talk to me on MSN at some point, but this isn't really core functionality.
  9. Damien New Member

    wordpress will deterimine who is entry author, try compare names
    $currentuser get_currentuserinfo();
    if ( 
    get_the_author() == $currentuser->displayname ) {
    // current user is the post author; do something

Share This Page