1

I want to create an author archive for only custom post type. This page will includes only custom posts by the author.

And url structure should be example.com/portfolio/author/author-name/

I don't want to include custom type to default author.php because my custom post type is in different language.

  • Someone else posted an answer to this question that I found even better, because it just appends the custom post type as a query to the URL for the author, thus loading the default archive page for the custom post type. Take a look here. – tommycopeland May 8 '18 at 11:47
0

According to this blogpost you just need to add the following code to your themes functions.php or in a plugin:

/* Add CPTs to author archives */
function custom_post_author_archive($query) {
    if ($query->is_author)
        $query->set( 'post_type', array('custom_type', 'post') );
    remove_action( 'pre_get_posts', 'custom_post_author_archive' );
}
add_action('pre_get_posts', 'custom_post_author_archive'); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.