Title: Show custom posts by author
Last modified: February 7, 2020

---

# Show custom posts by author

 *  Resolved [musoto](https://wordpress.org/support/users/musoto/)
 * (@musoto)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/show-custom-posts-by-author/)
 * Hi, this plugin is really great!
    How can I display Author posts for CPT only?
   Thanks a lot in advance.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [6 years, 4 months ago](https://wordpress.org/support/topic/show-custom-posts-by-author/#post-12410498)
 * To clarify, you’re looking for an author post archive of *just* posts for a specified
   post type?
 *  Thread Starter [musoto](https://wordpress.org/support/users/musoto/)
 * (@musoto)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/show-custom-posts-by-author/#post-12411677)
 * Exactly Sir.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [6 years, 4 months ago](https://wordpress.org/support/topic/show-custom-posts-by-author/#post-12411905)
 * 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](https://wordpress.org/support/users/musoto/)
 * (@musoto)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/show-custom-posts-by-author/#post-12412198)
 * Greate! it worked. Thank you so much.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [6 years, 4 months ago](https://wordpress.org/support/topic/show-custom-posts-by-author/#post-12413915)
 * Awesome to hear. Let us know if you need anything else.
 *  [azarmi93](https://wordpress.org/support/users/azarmi93/)
 * (@azarmi93)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/show-custom-posts-by-author/#post-12807135)
 * Hi [@tw2113](https://wordpress.org/support/users/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’ );

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Show custom posts by author’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-type-ui/assets/icon-256x256.png?rev=2744389)
 * [Custom Post Type UI](https://wordpress.org/plugins/custom-post-type-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-post-type-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-type-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-type-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-type-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-type-ui/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [azarmi93](https://wordpress.org/support/users/azarmi93/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/show-custom-posts-by-author/#post-12807135)
 * Status: resolved