Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我如何告诉wordpress模板是归档文件_Wordpress_Templates_Archive - Fatal编程技术网

我如何告诉wordpress模板是归档文件

我如何告诉wordpress模板是归档文件,wordpress,templates,archive,Wordpress,Templates,Archive,用例是我想在页面上列出最近的帖子。每篇文章只包含摘要、标题和全文链接 我已经创建了一个名为“最新帖子”的模板,它加载ok。但是,我想让get_content()以某种方式理解此模板是一个存档模板,因此只显示摘录而不显示全文 我将以下“内容”模板用于所有其他列表,并希望在列出我的最新文章时重复使用它,但由于它不是搜索或存档,因此跳过第一个选择,并且_content()将显示整个文章 <?php if ( is_search() ) : // Only display Excerpts for

用例是我想在页面上列出最近的帖子。每篇文章只包含摘要、标题和全文链接

我已经创建了一个名为“最新帖子”的模板,它加载ok。但是,我想让get_content()以某种方式理解此模板是一个存档模板,因此只显示摘录而不显示全文

我将以下“内容”模板用于所有其他列表,并希望在列出我的最新文章时重复使用它,但由于它不是搜索或存档,因此跳过第一个选择,并且_content()将显示整个文章

<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">
    <?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
    <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'bbl' ) ); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'bbl' ), 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>


解决方案是使用以下代码:

global $more;    // Declare global $more (before the loop).
....
$more = 0;       
....
有关此主题的更多信息,请参阅文档:

现在,\u content()将不会在more标记后显示任何内容

它并不是真的告诉引擎这是一个归档页面,而是模拟了它的行为