Forums

[resolved] Coding PHP to detect different authors (3 posts)

  1. smith116
    Member
    Posted 3 years ago #

    I want to have two different post areas on my blog. I am setting up two authors and want them to have their own post spaces. I thought that I would modify our current theme's css to have two dedicated areas. I suppose what I need is an if, then, else statement in php to add to my index page. Can anyone demonstrate how to test the author variable in php and give it a conditional command? Thanks much.

  2. Dagon Design
    Member
    Posted 3 years ago #

    http://codex.wordpress.org/Template_Tags/get_the_author

    "Grabs the value in the user's Display name publicly as field. "

    <?php
    $author = get_the_author();
    if ($author == 'User1') {
    
    } else if ($author == 'User 2') {
    
    } else {
    
    }
    ?>

    There are some other functions too, if you want to compare by other things, such as their email address.

  3. smith116
    Member
    Posted 3 years ago #

    Thanks!

    I somehow just got it to work in query_post and then ran the loop again, query_post with a new author.

Topic Closed

This topic has been closed to new replies.

About this Topic