I can't seem to get any results to show up, even though I know for a fact that the content exists! Here's my code (search.php)

/* Template Name: Search */


<!--content -->
<div id="content">
    <div class="container">
        <div class="breadcrumbs"><?php
if (function_exists('bcn_display')) {
        $sidebar = get_post_meta($post->ID, 'wpcf-sidebar-template', true);
        if ($sidebar == 'disable') {
            <style type="text/css">
                #page {
                    width:100% !important;

        <?php }
        <section id="page">
            <h2><?php the_title(); ?></h2>
            if (have_posts()) : while (have_posts()) : the_post();
                <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
            <?php endif;


        if (function_exists('dynamic_sidebar')) {
            if (!($sidebar)) {
                if (is_admin()) {
                    echo _e('No sidebar preferences are defined.');
            } else {

                if ($sidebar != 'disable') {
                    echo '<aside id="sidebar">';
                    dynamic_sidebar('sidebar-' . $sidebar);
                    echo '</aside>';

        <div class="clear"></div>
    <!--/content --> 
  • Do you see 'Sorry, no posts matched your criteria.'? – s_ha_dum Jun 4 '13 at 23:11
  • Yup, the query is empty.... search refuses to work for some reason. – user2430162 Jun 4 '13 at 23:55
  • The search happens before that page loads. The problem is elsewhere, but I don't know where. Disable plugins and switch themes and try to narrow it down. – s_ha_dum Jun 5 '13 at 1:21
  • the global query seems to be altered somewhere.try debugging if you have made new wp_query() before try resetting it with wp_reset_query() or if you have used query_post() use wp_query instead – Dipesh KC Jun 5 '13 at 1:33
  • try to search for functions that hook with pre_get_posts, to me there is some function that alters search query: $query->is_search – JMau Jun 5 '13 at 2:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.