不会显示我的搜索结果。相反,搜索显示的是404。看见https://startupsagainstcorona.com/solutions/ 用于测试。有人能帮忙吗?
我做了什么?
我使用get\\u search\\u form()实现了标准的WP搜索。正如你在页面上看到的,这很好我添加了搜索。php和searchform。模板根文件夹中的php。这些PHP来自WP的2017个模板,因为我使用的是自定义模板,文件已经丢失。searchform布局相应更改。
不幸的是,搜索。php似乎在某种程度上是不活跃的。每次输入搜索时,都会发送404。
这里是搜索代码。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">
<?php
if ( have_posts() ) :
/* Start the Loop */
while ( have_posts() ) :
the_post();
/**
* 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.
the_posts_pagination(
array(
\'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>
<?php
get_search_form();
endif;
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php //get_sidebar(); ?>
</div><!-- .wrap -->
<?php
get_footer();
这里是searchform的代码。php:
<?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>
</label>
<input type="search" id="<?php echo $unique_id; ?>" class="search-field" placeholder="<?php echo esc_attr_x( \'Search …\', \'placeholder\', \'twentyseventeen\' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
</form>
感谢您的任何提示。
最好的,Max