首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress TwentyTwenty主题搜索结果页

Wordpress TwentyTwenty主题搜索结果页
EN

Stack Overflow用户
提问于 2020-01-13 21:18:38
回答 1查看 745关注 0票数 1

我正在使用TwentyTwenty主题。在搜索结果页面中,它只显示搜索结果文本。我想在搜索结果文本下面显示这些页面的固定链接。要编辑哪个文件。

提前感谢

代码语言:javascript
复制
<?php

$archive_title    = '';
$archive_subtitle = '';

if ( is_search() ) {
    global $wp_query;

    $archive_title = sprintf(
        '%1$s %2$s',
        '<span class="color-accent">' . __( 'Search:', 'twentytwenty' ) . '</span>',
        '&ldquo;' . get_search_query() . '&rdquo;'
    );

    if ( $wp_query->found_posts ) {
        $archive_subtitle = sprintf(
            /* translators: %s: Number of search results */
            _n(
                'We found %s result for your search.',
                'We found %s results for your search.',
                $wp_query->found_posts,
                'twentytwenty'
            ),
            number_format_i18n( $wp_query->found_posts )



        );
    } else {
        $archive_subtitle = __( 'We could not find any results for your search. You can give it another try through the search form below.', 'twentytwenty' );
    }
} elseif ( ! is_home() ) {
    $archive_title    = get_the_archive_title();
    $archive_subtitle = get_the_archive_description();

}

if ( $archive_title || $archive_subtitle ) {
    ?>
EN

回答 1

Stack Overflow用户

发布于 2020-01-13 22:40:22

我用以下简单的代码创建了search.php:

代码语言:javascript
复制
<?php 
/**
 * Template Name: Search Page
 */
?>
<?php get_header(); ?>

<main id="site-content" role="main">

<?php /* Start the Loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>
        <div class="container" style="font-size: 17px;">
            <div class="row">
                <div class="col-md-12">

        <div class="search-post-excerpt"><?php the_excerpt(); ?></div>
        <div class="search-post-link" style="margin-bottom: 10px;"><a href="<?php the_permalink(); ?>"><?php the_permalink(); ?></a></div>
        <hr>
                 </div>
            </div>
        </div>
        <?php endwhile; ?>



<?php get_footer();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59717457

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档