It is necessary that on the category page only posts with a specific tag are displayed, and the posts of the category itself should not be taken into account. Those. need to change the contents of the main request. If you make a request through new wp_query, then the pagination breaks. At the moment there is such code in the functions.php file:
function pre_get_post_by_tag( $query ) { if ( is_category() && $query->is_main_query() ) { $query->set('tag', 'boys'); } } add_action('get_post_by_tag', 'pre_get_post_by_tag' ); boys - the name of the tag.
and a call in the archive.php file
do_action('get_post_by_tag'); now gives the error "Fatal error: Call to a member function is_main_query () on string in ...."
How to fix the error? Is it correct to change the query in this way? Can there be any other ways to achieve the desired? I will be glad to any help.