Title: WordPress Defalut Search
Last modified: September 1, 2016

---

# WordPress Defalut Search

 *  Resolved [csem](https://wordpress.org/support/users/csem/)
 * (@csem)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/wordpress-defalut-search/)
 * Hello ,
 * Anyone know how can we use wordpress default search work only for post.
 * can anyone know proper solution for this issue.
 * **Thanks,**

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

 *  Anonymous User 14379775
 * (@anonymized-14379775)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/wordpress-defalut-search/#post-7492158)
 * Hi, open your theme’s functions.php file and paste this code:
 *     ```
       function search_filter($query) {
         if ( ! is_admin() && $query->is_main_query() ) {
       	if ($query->is_search) {
       	  $query->set('post_type', 'post');
       	}
         }
       }
       add_action( 'pre_get_posts', 'search_filter' );
       ```
   
 *  Thread Starter [csem](https://wordpress.org/support/users/csem/)
 * (@csem)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/wordpress-defalut-search/#post-7492170)
 * Yes its working.
    **Thanks.**

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

The topic ‘WordPress Defalut Search’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [csem](https://wordpress.org/support/users/csem/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/wordpress-defalut-search/#post-7492170)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
