[英]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. 当我单击顶部菜单中Helena Recipes搜索栏上的任何搜索结果时,我会自动重定向到主页,而不是相应的帖子。 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:
然后,我通过添加以下内容来编辑searchform.php代码:
name="s"
But it does not help. 但这无济于事。 This is the code I have in the searchform.php:
这是我在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: 这是我在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. 但是,search.php即将在页脚之前显示另一个搜索的结果(您可以在主页底部看到它),并且工作正常。 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://
. 缩略图问题:它们通过
http://
协议而不是https://
加载。 And this is causing Mixed content
errors, which stops loading images. 这会导致
Mixed content
错误,从而停止加载图像。 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. 从搜索表单重定向到首页的问题:看起来像一些
.htaccess
规则:搜索的所有结果页面/帖子均带有http://
协议,点击它们后,网站仅从http://{your-website}/{some-post}
重定向http://{your-website}/{some-post}
到首页。 It can be done through .htaccess
rules, with some javascript
, with php
and from the database. 可以通过
.htaccess
规则,一些javascript
, php
和数据库来完成。
@jack : You are using URL with http instead try with https as your domain has SSL certificate installed. @jack:您正在使用带有http的URL,而不是尝试使用https,因为您的域已安装SSL证书。 So, http will not work.
因此,http将不起作用。
http://www.helenarecipes.com/recipe/peaches-tomatoes-quinoa-salad/ http://www.helenarecipes.com/recipe/peaches-tomatoes-quinoa-salad/
instead try below URL in search listing 而是尝试在搜索列表中的URL下方
https://www.helenarecipes.com/recipe/peaches-tomatoes-quinoa-salad/ https://www.helenarecipes.com/recipe/peaches-tomatoes-quinoa-salad/
Hope this helps you. 希望这对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.