Title: Exclude post types
Last modified: April 8, 2022

---

# Exclude post types

 *  Resolved [swinggraphics](https://wordpress.org/support/users/swinggraphics/)
 * (@swinggraphics)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-post-types-7/)
 * How do you exclude post types from the index?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [swinggraphics](https://wordpress.org/support/users/swinggraphics/)
 * (@swinggraphics)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-post-types-7/#post-15541543)
 * Is this the best/only way?
 *     ```
       add_filter( 'wpfts_index_post', function( $index, $post ) { 
           if ( 'my_cpt' == $post->post_type ) {
               $index[ 'post_title' ] = '';
               $index[ 'post_content' ] = '';
           } 
           return $index; 
       }, 3, 2 );
       ```
   
 * Would I also need to add `$index[ 'clust_name' ]` line for each custom cluster?
 *  Plugin Author [Epsiloncool](https://wordpress.org/support/users/epsiloncool/)
 * (@epsiloncool)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-post-types-7/#post-15541602)
 * Hi [@swinggraphics](https://wordpress.org/support/users/swinggraphics/)
 * Yes, if you really want to remove some post types from search, it’s the good 
   code.
    However this makes impossible to search those posts too.
 * Alternatively you can use pre_get_posts hook (since we haven’t UI for this yet)
 *     ```
       add_action('pre_get_posts', function ($wpq){
           if ($wpq->is_search && $wpq->is_main_query()) {
                $wpq->set('post_type', array(...list of posts you want to search by...));
                $wpq->set('post_status', array('publish'));  // You can justify the list of statuses too
           }
       });
       ```
   
 * No, you don’t need to add ‘clust_name’, why?
 *  Thread Starter [swinggraphics](https://wordpress.org/support/users/swinggraphics/)
 * (@swinggraphics)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-post-types-7/#post-15541618)
 * Thanks. It’s good to note that `pre_get_posts` can filter results, but I am specifically
   looking to reduce the size and time of indexing. My site with 300 pages took 
   15 minutes to index. As I tweak and customize, I’ll have to rebuild. I don’t 
   want to keep waiting that long. Same site with Relevanssi took a few seconds.
 *  Plugin Author [Epsiloncool](https://wordpress.org/support/users/epsiloncool/)
 * (@epsiloncool)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-post-types-7/#post-15541629)
 * Yes, [@swinggraphics](https://wordpress.org/support/users/swinggraphics/), the
   indexing takes more time and space, mainly because WPFTS uses the TF-IDF principle
   that is different from the one used in Relevanssi. However, 300 pages for 15 
   minutes sounds a bit long for me. Anyway, it’s a one-time task and you don’t 
   need to rebuild the index too often (hopefully never) after the configuration
   of the wpfts_index_post hook.
 * We are still working on optimizations, anyway. And in the nearest future, it 
   will be possible to reindex only a touching set of posts (for example, only one
   post_type post, etc).
 * Thanks for your notice, it’s important to make more quality product.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Exclude post types’ is closed to new replies.

 * ![](https://ps.w.org/fulltext-search/assets/icon-256x256.png?rev=3084761)
 * [WP Fast Total Search - The Power of Indexed Search](https://wordpress.org/plugins/fulltext-search/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/fulltext-search/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/fulltext-search/)
 * [Active Topics](https://wordpress.org/support/plugin/fulltext-search/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/fulltext-search/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/fulltext-search/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Epsiloncool](https://wordpress.org/support/users/epsiloncool/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/exclude-post-types-7/#post-15541629)
 * Status: resolved