Adding custom post types to archive
Question
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.
0
custom-post-types
4 years
2020-03-25T00:53:47-05:00
2020-03-25T00:53:47-05:00 0 Answers
119 views
0
Leave an answer