[Support request] Authorship and more custom fields help

Home Forums Support [Support request] Authorship and more custom fields help

Home Forums Support Authorship and more custom fields help

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #978715
    Michael

    I currently need the author and person who reviewed the article to show up on reviewed posts. Something like:
    Written by THIS PERSON
    Reviewed by ANOTHER PERSON

    Could you point me in the right direction on how to achieve this?

    #978920
    David
    Staff
    Customer Support

    Hi there,

    you could use the WordPress Custom Fields (CF):

    https://wordpress.org/support/article/custom-fields/

    For this example we are creating a CF called reviewer

    Once the CF is set we can add some code to output it to the site using a Hook Element:

    https://docs.generatepress.com/article/hooks-element-overview/

    Create a new hook give it a title and add this to the content:

    <?php 
     
    $reviewer = get_post_meta($post->ID, 'reviewer', true);
     
    if ($reviewer) { ?>
        
        <span class="reviewers-name" itemprop="name"><? echo $reviewer; ?></span>
     
    <?php 
     
    } else { 
    // display nothing; 
    }
     
    ?>

    Select the after_entry_title hook, check Execute PHP and set the display rules to Posts > All Posts. If you want it to display on the Blog and Archives. Then you can add them as additional locations.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.