Site logo

Archived topic

Authorship and more custom fields help

1 reply · Started by Michael on August 7, 2019

Viewing posts 1–2 of 2

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?

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.

This archived topic is closed to new replies.