WordPress search only works with posts, not pages

I'm working on my own custom WordPress theme, using a blank, default template to start. I haven't edited the search.php file.

Many of my WordPress posts are Pages. Unfortunately, the site search only retrieves posts, not pages.

Any idea how to get the theme to search both posts and pages?

Here is the majority of search.php:

<?php if (have_posts()) : ?>

    <h3>Search Results</h3>

    <?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>

    <?php while (have_posts()) : the_post(); ?>

        <div <?php post_class() ?> id="post-<?php the_ID(); ?>">

            <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>

            <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>

            <div class="entry">
                <?php the_excerpt(); ?>


    <?php endwhile; ?>

    <?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>

<?php else : ?>

    <h3>No posts found.</h3>

<?php endif; ?>


Lack of page search and search results ranked by post date instead of relevance is a typical WP problem. Try http://wordpress.org/extend/plugins/relevanssi/

Add this code to your functions.php file.

function wpshock_search_filter( $query ) {
    if ( $query->is_search ) {
        $query->set( 'post_type', array('post','page') );
    return $query;


WP Search http://wpsear.ch/ has that ability.You can adjust what post types you want to show in results page.

Need Your Help

How to detect if changes were made in the preferences?

android sharedpreferences android-preferences preferenceactivity

I have a class that extends PreferenceActivity and shows the preference screen of my app. Is it possible to check if any changes were made to the preferences?

Buttons aligned to bottom of page conflict with mobile Safari's menu bar

html ios css mobile safari

I am building a web-portal which has to be functional and pretty on multiple platforms.