Support » Fixing WordPress » Getting "the_author" as tag or customfield meta?

  • Hi!

    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!

    AD

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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.

    http://codex.wordpress.org/Custom_Fields
    http://codex.wordpress.org/Function_Reference/get_post_meta

    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…

    Thanks!

    AD

    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:

    <?php
    $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>';
    }
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Getting "the_author" as tag or customfield meta?’ is closed to new replies.