I am wanting to dispaly custom post types on my archive pages using code from here:
https://wordpress.stackexchange.com/questions/179023/adding-custom-post-types-to-archive-php
but this now gives WP error message of:
Warning: Invalid argument supplied for foreach() in /wp-includes/class-wp-post-type.php on line 613
add_action('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if($query->is_main_query()
&& ( is_category() || is_tag() )) {
$query->set( 'post_type', array('post','cpt') );
}
}
Please let me know what changes are needed to not return errors.
has_archive
is true when registering the post type you will get an archive automatically at/asana/