0

I have one of those "wtf" problems again. I can't figure why my search form shows no result. See this webpage: http://sindlar.cz/exemplum/?lang=en

There is get_search_form() in the header. I also created searchform.php:

 <div class="search">
  <div class="search-field">
<form role="search" method="get" id="searchform" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
    <input type="search" value="<?php echo get_search_query(); ?>" placeholder="" name="s" id="s" class="search-input search-item" >
    <input type="submit" value="" class="search-button search-item">
</form>

And search.php:

    <section id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

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

            <header class="page-header">
                <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'shape' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
            </header><!-- .page-header -->

            <?php shape_content_nav( 'nav-above' ); ?>

            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>

                <?php get_template_part( 'content', 'search' ); ?>

            <?php endwhile; ?>

            <?php shape_content_nav( 'nav-below' ); ?>

        <?php else : ?>

            <?php get_template_part( 'no-results', 'search' ); ?>

        <?php endif; ?>

        </div><!-- #content .site-content -->
    </section><!-- #primary .content-area -->

The searchpage is opened after clicking on the search button but there are no result. Maybe is there any problem with database or anything? Do you have any ideas?

I also noticed that there is difference between searching actual content of the websites. For example if you type "About us", it will show the search.php but no results on it. On the other hand if you type "Big truck" or "fsdgwdhs", it will send back other page than search.php. So I think that wordpress maybe know that there are some results but it does not show them. I do not know.

Thanks!

  • There's a syntax error. Enable debug from wp-config.php to see what the error is. – Aniruddha Gawade Sep 15 '17 at 10:38
  • Thanks! It shows only fatal error search.php on line 12 and 21. That means <?php shape_content_nav( 'nav-above' ); ?> and <?php shape_content_nav( 'nav-below' ); ?> from the code above. If I erase them, there is fatal error no more but I still cannot see any results. See link – Hynek Kaplan Sep 29 '17 at 7:38
  • There are results to query. Since your no result page is not breaking. You can comment shape_content_nav( 'nav-above' ); and shape_content_nav( 'nav-below' ); and print your queries to debug. – Aniruddha Gawade Sep 29 '17 at 8:07
  • OK, I commeted them but now there is no error at all. See sindlar.cz/exemplum/?s=o+nás – Hynek Kaplan Sep 29 '17 at 8:27
  • One more thing, if I type nonesene into field, it shows me this: SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (264,2,12,16) AND wp_posts.post_type = 'page' AND ((wp_posts.post_status = 'publish')) AND (wp_posts.post_content='' OR wp_posts.post_content LIKE '%![:cs!]%' ESCAPE '!' OR wp_posts.post_content LIKE '%%' OR (wp_posts.post_content NOT LIKE '%![:!]%' ESCAPE '!' AND wp_posts.post_content NOT LIKE '%%')) ORDER BY wp_posts.post_date DESC – Hynek Kaplan Sep 29 '17 at 8:33
0

The template that responsible to display your search result is:

get_template_part( 'content', 'search' );

I thought its located in content directory in your themes, file name search.php maybe.

  • ? Did you read my question? – Hynek Kaplan Sep 29 '17 at 7:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.