function searchfilter($query) { if ($query->is_search && !is_admin() && !is_woocommerce()) { $query->set('post_type','post'); } return $query; } add_filter('pre_get_posts','searchfilter');
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter