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

    (@msaari)

    Yes. There are many ways to do this, and the best way depends on how many posts you want to include and how often you need to change the posts included.

    I’d do this by enabling posts in the site search, but then disabling indexing for all posts excepts those you want to include.

    add_filter('relevanssi_do_not_index', 'post_indexing_filter', 10, 2);
    function post_indexing_filter($index, $post_id) {
        $posts_to_include = array(1, 2, 3);
        if (in_array($post_id, $posts_to_include)) return true;
        return false;
    }

    Put this function in functions.php and list the posts you want to include in the $posts_to_include array. Then rebuild the index, and only the posts you want to include will be indexed.

    Thread Starter miketopher

    (@miketopher)

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Include specific posts in search?’ is closed to new replies.