title

Add custom post types to archives page

 

Add custom post types to archives page

10 Mai 2013, Posted by antoine in

Adding this snippet to the functions.php of your wordpress theme will let you add custom post types to archives page.

function add_custom_types_archive( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
 'post', 'your-custom-post-type-here'
            ));
      return $query;
    }
}
add_filter( 'pre_get_posts', 'add_custom_types_archive' );