我想使用以下代码在存档页上显示自定义帖子类型:
https://wordpress.stackexchange.com/questions/179023/adding-custom-post-types-to-archive-php
但这现在给出了WP错误消息:警告:为/wp includes/class wp post type中的foreach()提供的参数无效。php在线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\') );
}
}
请让我知道需要哪些更改才能不返回错误。