WordPress Archive Page for Custom Post Types

add_action( ‘pre_get_posts’, ‘add_custom_post_types_to_loop’ );

function add_custom_post_types_to_loop( $query ) {

if ( is_home() && $query->is_main_query() )

$query->set( ‘post_type’, array( ‘post’, ‘portfolio’ ) );

return $query;

}

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top