Getting "the_author" as tag or customfield meta? (4 posts)

  1. arthurdent2003
    Posted 4 years ago #


    is there a way to get "the_author" meta to a custom field?

    E.g. I have several posts from different Authors, but for searching on frontend, it would be great to find all posts by a specific author - Name and Lastname.

    So I would like to have the_author also appear as a Tag.

    Any idea??

    Thank you!


  2. curtismchale
    Posted 4 years ago #

    You're going to have to add a custom_meta key with the author name as the value. Then you're going to have use get_post_meta to call the fields in to the post.


  3. arthurdent2003
    Posted 4 years ago #

    Hi Crutis,

    thanks for the reply. But can I get the value from "the_author" to be automatically the "value" of the custom field. I just want to let a guest author put in his Name in the author field - that's "the_author" - but not into two different fields. So my idea is to get the value from the existing "the_author" meta...



  4. Big Bagel
    Posted 4 years ago #

    It would help to know exactly what you're trying to do. Your first post suggested you wanted to just put the author's name on the posts, link to the author's page, or add the author to the terms searched for. Your second post suggests you want to allow guest authors, who don't have a user account, to add their name to a custom field and have that displayed instead of the_author(). If so:

    $guest_author = get_post_meta( $post->ID, 'author', true );
    if ( ! empty( $guest_author ) ) {
        echo $guest_author;
    } else {
        echo '<a href="' . get_author_posts_url( get_the_author_meta( "ID" ) ) . '" rel="author">' . get_the_author() . '</a>';

Topic Closed

This topic has been closed to new replies.

About this Topic