• Resolved azarmi93

    (@azarmi93)


    Hi.

    I’m trying to create an author archives template which shows the CPTs I created per author.

    The archives widget yeilds no results.

    Also, creating a search results archive page also doesn’t pull in CPTs.

    Please let me know how I can fix these.
    Many thanks!

Viewing 1 replies (of 1 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Replying her since i saw you responded to a different already closed thread.

    This code that you provided there should be doing the trick.

    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' );
    

    I guess my questions are
    1) Do they have any published post types from this post to be included in the listing?
    2) Are you sure you’re visiting the right URL?

Viewing 1 replies (of 1 total)

The topic ‘Author Archive CPTs’ is closed to new replies.