Forums

[resolved] Don't show byline if by author X (5 posts)

  1. marissawells
    Member
    Posted 2 years ago #

    I'm having an issue with bylines. The editor of the blog I'm developing needs the byline to show only if the author is not Author X.

    So: If author does not equal Author X - display byline

    However, I'm not sure how to test for the author's name/ID in an if statement since it seems that all of the author tags I've tried print the author data on the page, and I need to use it simply for testing.

    Any ideas?

  2. stvwlf
    Member
    Posted 2 years ago #

    <?php define ('AUTHOR_X_ID', '16');
    $author_id = get_the_author_ID();
    
    if ( $author_id != AUTHOR_X_ID ) {
      display byline
    }; ?>
  3. marissawells
    Member
    Posted 2 years ago #

    Wow, much easier than I expected! Thanks so much!

  4. Walker
    Member
    Posted 1 year ago #

    How does this work when there is NO FUNCTION called get_the_author_ID()?

  5. MichaelH
    Volunteer
    Posted 1 year ago #

    If used in a The Loop then something like:

    <?php
    $author_id = $post->post_author;
    if ( $author_id != 1 ) {
      //display byline for all but user ID 1
    }
    ?>

    Related:
    How do I determine a Post, Page, Category, Tag, Link, Link Category, or User ID?
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

Topic Closed

This topic has been closed to new replies.

About this Topic