[Resolved] List Custom Post Types Posts on Author page
This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Hello
I'm trying to display custom post types posts on the author page (the default one from wp that is listing posts written by the author). Is there any options that Toolset is providing for this?
You can use the function below in order to do this.
<?php
function post_types_author_archives($query) {
if ($query->is_author)
// Add 'books' CPT and the default 'posts' to display in author's archive
$query->set( 'post_type', array('books', 'posts') );
remove_action( 'pre_get_posts', 'custom_post_author_archive' );
}
add_action('pre_get_posts', 'post_types_author_archives');
?>
What you need to do is add the slug for the post type in array. Then add the following to the Toolset Custom code section in Toolset->Settings ->Custom Code and then activate it.
I'm using the Astra theme, but when I put this code in it's functions.php file or when I activate the Custom Code in Toolset it gives me a database error.