To clarify, you’re looking for an author post archive of *just* posts for a specified post type?
It’s going to be a custom code solution, one way or another, as there’s no built in way to do that now, from what I’ve heard and seen. If there is, I’m willing to be wrong 😀
That said, some questions
1. is this author going to have standard blog posts as well that need to be able to be seen in an author archive? If no, then this snippet should help out:
function wpse107459_add_cpt_author( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( $query->is_author() ) {
$query->set( 'post_type', array( 'YOUR_CUSTOM_POST_TYPE' ) );
}
}
add_action( 'pre_get_posts', 'wpse107459_add_cpt_author' );
2. How important is the URL permalink? Asking this one because it likely could be possible to set up a custom query on some page or so, to include extra data like posts from this post type and a found author.
Thread Starter
musoto
(@musoto)
Greate! it worked. Thank you so much.
Awesome to hear. Let us know if you need anything else.
Hi @tw2113 !
I’m so glad I found someone who knows how to address this issue 😀
I have essentially the same problem whereby I am trying to create an Author Archive Page in which CPTs will be drawn in.
I have copied in the exact code as given above into my functions.php folder, however unfortunately I haven’t had success.
My CPT slug is ‘offers’ and I have inputted this into the array feild as required:
function wpse107459_add_cpt_author( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( $query->is_author() ) {
$query->set( ‘post_type’, array( ‘offers’ ) );
}
}
add_action( ‘pre_get_posts’, ‘wpse107459_add_cpt_author’ );