Support » Fixing WordPress » Custom Post Type archive index page now working

  • I have a custom post type set up, “products”, using the “Types” plugin. I have a theme file called “single-products.php” that is working fine, but “archive-products.php” is not being loaded by WP.
    For background, in order to get this CPT working, I needed to add this code to my functions.php file:

    // Add custom post types to regular queries
    // if not a normal page, return the 'products' post type
    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts( $query ) {
    	if ( !is_admin() && !is_page() && false == $query->query_vars['suppress_filters'] )
    		$query->set( 'post_type', array( 'products' ) );
    	return $query;

    This site doesn’t use regular posts so I only want to display products. They are showing up fine except for the archive index problem mentioned above. Anyone have suggestions?

  • The topic ‘Custom Post Type archive index page now working’ is closed to new replies.