My search-results are not displayed. Instead searches show a 404. See https://startupsagainstcorona.com/solutions/ for testing. Can someone help?

What did I do?

  1. I implemented the standard WP-search using get_search_form(). This worked fine, as you can see on the page.
  2. I added the search.php and searchform.php in the root-folder of the template. Those phps came from the twentyseventeen-template of WP, as I am using a custom template and the files have been missing.

    The searchform-layout changed accordingly.

Unfortuntately, the search.php seems to be inactive in a way. Everytime, entering a search, delivers a 404.

Here the code of the search.php:

<get_header(); ?>

<div class="wrap">

    <header class="page-header">
        <?php if ( have_posts() ) : ?>
            <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyseventeen' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
        <?php else : ?>
            <h1 class="page-title"><?php _e( 'Nothing Found', 'twentyseventeen' ); ?></h1>
        <?php endif; ?>
    </header><!-- .page-header -->

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

        if ( have_posts() ) :
            /* Start the Loop */
            while ( have_posts() ) :

                 * Run the loop for the search to output the results.
                 * If you want to overload this in a child theme then include a file
                 * called content-search.php and that will be used instead.
                get_template_part( 'template-parts/content', 'search' );

            endwhile; // End of the loop.

                    'prev_text'          => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>',
                    'next_text'          => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
                    'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>',

        else :

            <p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'twentyseventeen' ); ?></p>


        </main><!-- #main -->
    </div><!-- #primary -->
    <?php //get_sidebar(); ?>
</div><!-- .wrap -->


And here the code for the searchform.php:

 * Template for displaying search forms in Twenty Seventeen
 * @package WordPress
 * @subpackage Twenty_Seventeen
 * @since 1.0
 * @version 1.0


<?php $unique_id = esc_attr( twentyseventeen_unique_id( 'search-form-' ) ); ?>

<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
    <label for="<?php echo $unique_id; ?>">
        <span class="screen-reader-text"><?php echo _x( 'Search for:', 'label', 'twentyseventeen' ); ?></span>
    <input type="search" id="<?php echo $unique_id; ?>" class="search-field" placeholder="<?php echo esc_attr_x( 'Search &hellip;', 'placeholder', 'twentyseventeen' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />

Appreciate any hint.

Best, Max

  • The action field of the form is https://startupsagainstcorona.com/, shouldn't that be https://startupsagainstcorona.com/solutions/? – Jos Apr 2 '20 at 12:28
  • Great hint! That was the solution! Changed it and it works :):) Thanks Jos!! – Max Marquart Apr 2 '20 at 12:32
  • Please allow me to state that as an answer. – Jos Apr 2 '20 at 12:35

The action field of the search form refers to https://startupsagainstcorona.com, which is the root of the web server.

However, apparently Wordpress is installed at https://startupsagainstcorona.com/solutions, which is where the action field should refer to.


Can you try flushing your permalinks. This can be done by visiting the Permalinks under settings and hitting 'Save Changes'

  • Just did this but did unfortunately not help. Is it enough to visit the "Permalinks" and hit "Save" without changing? :) – Max Marquart Apr 2 '20 at 12:31

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.