Reputation: 21
I'd like to alter the search results in some part of a Wordpress website.
Les results should be childs of pages 425 or 2064, OR childs of categories 9 or 63.
I don't think it's possible with wp_query
. Maybe something like :
global $wp_query;
$args = array(
's' => $s,
'paged' => $paged,
'post_parent__in' => array( 425, 2064 ),
'category__in' => array( 9, 63 ),
);
$wp_query = new WP_Query($args);
Any help will be welcome.
Upvotes: 0
Views: 42
Reputation: 21
Finally, I filtered the posts
<?php
// filtered content
$first_parent_page = 425;
$second_parent_page = 2064;
$first_parent_cat = 9;
$second_parent_cat = 63;
if (
// in pages and sub-pages
$post->post_parent==$first_parent_page || $post->post_parent==$second_parent_page
// in cat
|| in_category( [$first_parent_cat,$second_parent_cat] )
// in sub-cat
|| (get_term_children($first_parent_cat,'category') && in_category((get_term_children($first_parent_cat,'category'))))
|| (get_term_children($second_parent_cat,'category') && in_category((get_term_children($second_parent_cat,'category'))))
) { ?>
Upvotes: 1