简体   繁体   中英

WordPress Live Search Results Redirect to Homepage

When I click on any search result on Helena Recipes search bar in top menu I am automatically redirected to the homepage instead of the corresponding post. Thumbnails do not show up either (although they should, next to the titles).

I tried switching themes and testing plugins. None of them seem to be the reason. I then edited the searchform.php code by adding:

  name="s"

But it does not help. This is the code I have in the searchform.php:

  <form method="get" class="search-form" action="<?php echo home_url( '/' ); ?>" autocomplete="off">
    <div class="search-field-w">
      <input type="search" autocomplete="off" class="search-field" placeholder="<?php echo esc_attr_x( 'Search …', 'placeholder', 'osetin' ) ?>" value="<?php echo get_search_query() ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label', 'osetin' ) ?>" />
      <input type="submit" class="search-submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'osetin' ) ?>" />
    </div>
  </form>

And this is the code I have in my search.php:

  <?php
  /**
   * The template for displaying search results page
  */

  get_header(); 

  $layout_type_for_index = osetin_get_settings_field('layout_type_for_index');

  ?>
  <div class="os-container">
    <div class="page-intro-header without-background">
      <h2><?php printf( __( '"%s" <span class="smaller-text">Query Search Results</span>', 'osetin' ), ucwords(get_search_query()) ); ?></h2>
    </div>
  </div>

  <div class="os-container">
    <?php global $wp_query; ?>
    <?php echo build_index_posts($layout_type_for_index, 'sidebar-index', $wp_query); ?>
  </div>

  <?php get_footer(); ?>

However, the search.php is about showing the results of a different search (you can see it in the bottom of the main page ), right before the footer, and it works fine. The issue is in the "live" search functionality as it is supposed to take you to the corresponding post.

What am I missing?

I looked at your website. The problem is not with your search bar.

Issue with thumbnails: they are loading through http:// protocol instead of https:// . And this is causing Mixed content errors, which stops loading images. That's why you can't see them.

The problem with redirect from search form to homepage: it's look like some .htaccess rules: all result pages/posts from search is with http:// protocol and after clicking on them the website just redirects from http://{your-website}/{some-post} to homepage. It can be done through .htaccess rules, with some javascript , with php and from the database.

@jack : You are using URL with http instead try with https as your domain has SSL certificate installed. So, http will not work.

http://www.helenarecipes.com/recipe/peaches-tomatoes-quinoa-salad/

instead try below URL in search listing

https://www.helenarecipes.com/recipe/peaches-tomatoes-quinoa-salad/

Hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM