简体   繁体   中英

Wordpress: Match custom field to page title and display related posts

I have a custom field named article_author. It is used to display the name of the author. Many different users upload articles on behalf of the authors.

All authors have a page with their details, bio etc on it.

I would like to display the latest 5 posts by the author on their bio page by matching the page title to the custom field.

I have no idea how to go about doing this, I have searched the web for weeks but still no luck. I am new to php and wordpress.

Would appreciate any help you guys can offer.

Many thanks

How did you set up the bio pages? Are they using author.php ? Have you added the authors to the site as users?

If so you can assign the posts the author has written to their user, this way when the author.php template is loaded, the loop will already contain their latest 5 posts.

Eg, if you have a user called 'Steve' and assign two posts to him, when visiting http://www.yourwebsite.com/author/steve/ - this will load up the author.php file from your theme

More details on Author Templates here: http://codex.wordpress.org/Author_Templates

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM