Viewing 5 replies - 1 through 5 (of 5 total)
  • Try this in your theme’s functions.php

    Making sure the code goes inside the PHP tags.

    add_filter( 'pre_get_posts' , 'switch_search_to_pages' );
    function switch_search_to_pages( $query ) {
    
    	if( $query->is_admin )
    		return $query;
    
    	if( !$query->is_search )
    		return $query;
    
    	$query->set( 'post_type' , 'page' );
    
    	return $query;
    }

    Thread Starter vbpartners

    (@vbpartners)

    great! it worked.

    thanks ??

    You’re welcome.. ??

    Hello,

    How should we go about searching both the posts and pages ?

    It says that by default WP does that, newer than 2.5, but it doesn’t seem to work for us.

    Are you able to help ?

    Alexander

    WordPress searches posts and pages by default.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Search.php – to search pages too…?’ is closed to new replies.