Hide Pages from Search Results – Free Code Snippet – Elementor WordPress Tutorial

Add this to Code Snippets to stop Pages from appearing in your Search Results Template. This will show Posts and Products if you want.

if (!is_admin()) {
function mv_search_filter($query) {
if ($query->is_search) {
$query->set('post_type', array( 'post','product'));
return $query;

Please Share

Help us to create Amazing Content!