Skip to:
Content
Pages
Categories
Search
Top
Bottom

Rewrite Author Name with Custom Fields


  • myladeybugg
    Participant

    @myladeybugg

    I am allowing guest posts on my main blog without the guests having to create users. I am trying to implement code that overrides the output of the_author using a custom field, but can’t seem to get it to work.

    When I looked in the bp-default single.php I did not see a call to the_author, maybe I missed it, but I’m thinking this could be the issue.

    Here is the code I am working with:
    `add_filter( ‘the_author’, ‘guest_author_name’ );
    add_filter( ‘get_the_author_display_name’, ‘guest_author_name’ );

    function guest_author_name( $name ) {
    global $post;

    $author = get_post_meta( $post->ID, ‘guest-author’, true );

    if ( $author )
    $name = $author;
    return $name;
    }`

    Any ideas on how to get it to work?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Rewrite Author Name with Custom Fields’ is closed to new replies.
Skip to toolbar