WordPress.org

Support

Support » How-To and Troubleshooting » placeholder contributors / custom bylines

placeholder contributors / custom bylines

Viewing 1 replies (of 1 total)
  • Drew Jaynes

    @drewapicture

    Docs Czar

    There are a myriad of ways you could handle this. If you’re not keen on adding new contributors all the time, the multi-author plugins really won’t do you much good.

    Here’s a method I’ve used before:

    1. Add a new custom field where the key is contributor and the value is the contributor’s name.
    2. In your theme’s single.php file, if you’d like only the contributor’s name to show in the byline, you’ll need to locate where the_author(); or the_author_link(); is called and replace it with something like this:

    >> If you’ve added a ‘contributor’ custom field

    <?php if ( get_post_meta($post->ID, 'contributor', true) ) { ?>

    >> Display the contributor’s name in the byline

    <h2>By: <?php echo get_post_meta($post-ID, 'contributor', true) ?></h2>

    >> If not

    <?php } else { ?>

    >> Display the post author’s byline

    <h2>By: <?php the_author_link(); ?></h2>

    >> Endif

    <?php } ?>

    So your final code would look like this:

    <?php if ( get_post_meta($post->ID, 'contributor', true) ) { ?>
    <h2>By: <?php echo get_post_meta($post->ID, 'contributor', true) ?></h2>
    <?php } else { ?>
    <h2>By: <?php the_author_link(); ?></h2>
    <?php } ?>

    Related Reading:

    Hope that helps.

Viewing 1 replies (of 1 total)
  • The topic ‘placeholder contributors / custom bylines’ is closed to new replies.
Skip to toolbar