placeholder contributors / custom bylines (2 posts)

  1. upsidepolitics
    Posted 4 years ago #

    I run a blog where most of the time, I post on behalf of Contributors, and simply assign the post to their name (most of our collaboration is via email / Microsoft Word). Asking them to post themselves would take added time/hassle, especially since many of them don't use WordPress.

    Until now I've done this by creating a Contributor account for each new author. However this has the drawback of confusing them when they get email confirmation of a new account.

    What I would like is to create a Contributor account that is tied to my own email address, or alternatively to somehow have them listed in the byline without having an account.

    Is either idea possible, or is there another suggested way of doing this?

  2. Drew Jaynes
    Docs Czar
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic