• Hal

    (@halburgissnet)


    What I need to do is include all “posts”, and just a few, select “pages” (a client’s requirements). It seems the relevanssi_where filter is what I need. Current (non working) code is:

    add_filter( 'relevanssi_where', function ( $query_restrictions ) {
    	$new = str_replace( 'WHERE ' , "WHERE posts.post_parent IN ( 663, 284 ) OR ", $query_restrictions );
    	return $new;
    });

    I need the child pages of those 2 WP “pages”.

    “Pages” is disabled in Search Option Settings. If I enable that, the index of course includes all pages.

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari

    (@msaari)

    You want only to index pages that are children of 663 or 284? In that case you have to enable “page” post type in indexing, and then add this function:

    add_filter('relevanssi_do_not_index', 'rlv_only_some_pages');
    function rlv_only_some_pages($block, $post_id) {
        $post_type = get_post_type($post_id);
        if ($post_type == "page") $block = true;
        if ($post_id == 663 ||?$post_id == 284) {
            $block = false;
        }
        if ($block && $post_type == "page") {
            $parent = wp_get_post_parent_id($post_id);
            if ($parent == 663 ||?$parent == 284) $block = false;
        }
        return $block;
    }

    This will block all pages, except 663, 284 and their children.

Viewing 1 replies (of 1 total)
  • The topic ‘Selectively Adding Pages to Query’ is closed to new replies.