WordPress.org

Ready to get started?Download WordPress

Forums

Conditional Tag: has_author() ? (3 posts)

  1. Adam Capriola
    Member
    Posted 3 years ago #

    Hey there,

    I am reading over the Conditional Tags page and am wondering if there will every be a has_author() tag?

    I see there are is_author() tags which apply to archive pages, but I need something for authors that would work like in_category() or has_tag().

    I'm trying to display stuff within posts only for certain authors... right now the only way I see to do it is to manually tag a post for each of the authors and then display the additional content via has_tag() (or do the same via categories).

    But if would be great if there was a way to make a conditional solely based on the author that wrote it. I'd rather not have to add tags and categories to posts... the more automation the better.

    I may be missing something, but is this in the works or can it already be done??

    Thanks!

    -Adam

  2. Try using get_the_author in the Loop and performing your if statement based off the return value.

  3. Adam Capriola
    Member
    Posted 3 years ago #

    Ah good idea! I actually think using get_the_author_meta might be better for my situation, because I have a big site and people might have the same display name (or simply change it from time to time).

    That would allow me to do a conditional based on the login name.

    I just found this page and it look like it's got code that will do nearly exactly what I'd want: http://wordpress.org/support/topic/author-role-conditional-check?replies=7

    Just gotta replace user_level with whatever. Sweet!

Topic Closed

This topic has been closed to new replies.

About this Topic