• Resolved claudioandres

    (@claudioandres)


    When I do a search, redirects to the home page and not showing the results but the search term is in the url bar.

    I call the search form from the header.php with the function:
    get_search_form( true );

    and the search results page (search.php) have:

    <?php
    
        $s = get_search_query();
        $args = array(
                        's' =>$s
                    );
            // The Query
                $the_query = new WP_Query( $args );
                if ( $the_query->have_posts() ) {
                        _e("<h1>Resultados de busqueda para: <u>".get_query_var('s')."</u></h1>");
                        while ( $the_query->have_posts() ) {
                        $the_query->the_post();
                                ?>
                                    <li>
                                        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                    </li>
                                <?php
                        }
                    }else{
                ?>
                <h1>No hay coincidencias</h1>
                <div class="alert alert-info">
                    <p>Por favor intenta nuevamente la busqueda con otro término.</p>
                </div>
        <?php } ?>

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @claudioandres. The code you provided for the search form and search results page looks correct, so the issue might be caused by something else, such as a plugin conflict or theme settings.

    Please attempt to disable all plugins, and use one of the default (Twenty*) themes. If the problem goes away, enable them one by one to identify the source of your troubles. If you can install plugins, install and activate “Health Check”: https://ww.wp.xz.cn/plugins/health-check/ It will add some additional features under the menu item under Tools > Site Health. On its troubleshooting tab, you can Enable Troubleshooting Mode. This will disable all plugins, switch to a standard WordPress theme (if available), allow you to turn your plugins on and off and switch between themes, without affecting normal visitors to your site. This allows you to test for various compatibility issues. There’s a more detailed description about how to use the Health Check plugin and its Troubleshooting Mode at https://make.ww.wp.xz.cn/support/handbook/appendix/troubleshooting-using-the-health-check/

    Thread Starter claudioandres

    (@claudioandres)

    Hi @noisysocks,
    thanks for your reply. I did all that you tell me and the search form still with this error. There are any other steps that you have in mind to try to fix it? BTW, this server is an AWS with a Cloudfront configuration, could be something in the Cloudfront that prevents passing the var of the search form?

    Thread Starter claudioandres

    (@claudioandres)

    Hi @noisysocks, we already fix the error.
    The error was in the CloudFront, the engineer miss a configuration.
    Thanks for your comments.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Error on Search results’ is closed to new replies.