Home / guest / Guest author custom field
  • How to Guest author custom field

    no thumbnail sorry: Guest author custom field

    Adding this code to your functions.php file of your wordpress theme will let you add a custom field guest-author enter this authors name in the value field to change the author of the blog post.

    ( click code to copy )

    wordpress snippet : PHP

    <>
        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;
        }
    

    ( WordPress codex functions, hooks, in this snippet. )

    the_author, get_post, get_post_meta, get_the_author, add_filter, _n,