我正在创建我的站点(本地),我使用的是初学者主题underscores.me
我使用粗体、斜体和其他文本样式创建了几个页面,但我注意到在搜索结果页面中,显示页面的内容没有文本样式。
看一下这张图片,就能更好地理解这个问题:

我几乎可以肯定,为了定制搜索行为,我必须编辑文件searchform.php或search.php,但我不知道必须在其中写什么。
你能帮忙吗?
非常感谢
这里是我的search.php内容:
<?php
/**
* The template for displaying search results pages
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
*
* @package sitename
*/
get_header();
?>
<section id="primary" class="content-area">
<main id="main" class="site-main">
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title">
<?php
/* translators: %s: search query. */
printf( esc_html__( 'Search Results for: %s', 'sitename' ), '<span>' . get_search_query() . '</span>' );
?>
</h1>
</header><!-- .page-header -->
<?php
/* 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;
the_posts_navigation();
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
</main><!-- #main -->
</section><!-- #primary -->
<?php
get_sidebar();
get_footer();发布于 2019-06-11 21:16:18
通常情况下,当搜索结果将页面的内容提取到某一节进行节选时,它会通过运行strip_tags的筛选器或删除任何和所有HTML标记的等效WordPress特定函数来运行内容,从而不会因为打开的<div>标记没有关闭合作伙伴而中断站点,因为节选在适当关闭之前切断了结尾,然后可能会破坏站点的布局,以及其他原因,但这是最简单的例子。
要自定义行为,您可能需要编辑search.php或content-search.php (如果存在的话)以显示您自己版本的内容,无论是所有内容,还是修改后的摘录系统版本。
https://wordpress.stackexchange.com/questions/340217
复制相似问题