I already tried to add to functions.php the following codes:
add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if(is_category() || is_tag()) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array('post','review');
$query->set('post_type',$post_type);
return $query;
}
}
and
add_action( 'pre_get_posts', function ( $q )
{
if ( !is_admin() // Only target front end queries
&& $q->is_main_query() // Only target the main query
&& $q->is_category() // Only target category archives
) {
$q->set( 'post_type', ['post', 'review'] ); // Adjust as needed
}
});
It didn’t work.