Trying my best to wrap my head around wordpress search process and results.
Been reading and researching online for about 8 hours straight at this stage and have gotten almost nowhere.

I have a completely custom template. I have a search box in a nav bar at the top of the page, inside the header. I’d like the user to be able to search the site’s content from that search box in the nav bar at any time. I’ve found plenty of examples of this being accomplished on other pages, though they often seem to be using a ready-made theme.

Eventually I’d like to be able to understand what’s going in the search.php file well enough to edit it along with the searchform.php file so that the search box and results appear unified with the rest of the theme.
At the moment the closest I’ve gotten to having anything functioning at all is the inclusion of a quantity of search results showing the appropriate number of hits expected, but I still can not figure out how to display a result.
I’ve been combing through page sources and every hit I can google about customising or just explaining the search.php file, and yet all I keep finding is “read the Creating a Search Page” and “it must be a theme issue.” This is not gainful information.

My understanding of what’s being taught in the “Creating a Search Page” info is that it describes the steps for creating a custom search page that one can hyperlink / permalink to, but which is unrelated to the default search function within the wordpress kit. Indeed, I’ve successfully created a custom search page, but it behaves simply as a stand-alone page, and is not related to a customised search results page. To customise the look of default search function results, I understand the search.php file must be edited. So far the “what to edit” within that file escapes me, but for now I’d just like to understand why I am seeing the correct number of results, but no actual results.

My search.php file looks like this:

<?php get_header(); ?>
    <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', 'ewgi2014' ), get_search_query() ); ?></h1>
            </header><!-- .page-header -->
                    // Start the Loop.
                    while ( have_posts() ) : the_post();
                         * Include the post format-specific template for the content. If you want to
                         * use this in a child theme, then include a file called called content-___.php
                         * (where ___ is the post format) and that will be used instead.
                        get_template_part( 'content', get_post_format() );
                    // Previous/next post navigation.
                else :
                    // If no content, include the "No posts found" template.
                    get_template_part( 'content', 'none' );
        </div><!-- #content -->
    </section><!-- #primary -->
get_sidebar( 'content' );

*Note: The notes in CAPS are to help me understand what content is coming from where as I try to figure out what each phpiece of the puzzle is doing.

Also, the twentyfourteen_paging_nav line is commented out as it kept spitting back an error. The original search.php was from a (default theme?) folder called “twentyfourteen”. My current folder is called “ewgi2014″ however, replacing twentyfourteen_paging_nav with ewgi2014_paging_nav spat back the same error, and I can’t find any more useful information on the topic. Also, when looking at other sample search.php files I didn’t see the paging_nav call, so I tried commenting it out, and was able to at least avoid the error, though I still don’t understand it.

Not entirely relevant, I believe, but my searchform.php looks like this:

<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
        <input type="search" class="search-field" placeholder="search …" value="" name="s" title="Search for:" />
    <input type="submit" class="search-submit" value="Search" />

I’ve read and re-read the “Creating a Search Page” page from the Codex so many times I could probably recite it by heart, but haven’t found any solutions within.
I’ve read this and this .. and apparently I can’t link to all the other things I’ve read as this is my first post, but I have been reading a lot, and fiddling, and making very little headway.

Apologies for the long-winded post. Just trying to be thorough and show my research and current point of understanding.

Read more here: wordpress custom theme search has quantity but displays no results


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: