我正在尝试调整引导程序的基本主题,以便它显示摘录。它在使用搜索时执行此操作,但在默认情况下不执行此操作。
我正在试图找出我需要对内容进行哪些更改。php文件。谁能给个建议吗。
我已经试了好几个小时了,正在努力。代码如下:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<?php if (\'post\' == get_post_type()) { ?>
<div class="entry-meta">
<?php bootstrapBasicPostOn(); ?>
</div><!-- .entry-meta -->
<?php } //endif; ?>
</header><!-- .entry-header -->
<?php if (is_search()) { // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
<div class="clearfix"></div>
</div><!-- .entry-summary -->
<?php } else { ?>
<div class="entry-content">
<?php the_content(bootstrapBasicMoreLinkText()); ?>
<div class="clearfix"></div>
<?php
/**
* This wp_link_pages option adapt to use bootstrap pagination style.
* The other part of this pager is in inc/template-tags.php function name bootstrapBasicLinkPagesLink() which is called by wp_link_pages_link filter.
*/
wp_link_pages(array(
\'before\' => \'<div class="page-links">\' . __(\'Pages:\', \'wmillock\') . \' <ul class="pagination">\',
\'after\' => \'</ul></div>\',
\'separator\' => \'\'
));
?>
</div><!-- .entry-content -->
<?php } //endif; ?>
<footer class="entry-meta">
<?php if (\'post\' == get_post_type()) { // Hide category and tag text for pages on Search ?>
<div class="entry-meta-category-tag">
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list(__(\', \', \'wmillock\'));
if (!empty($categories_list)) {
?>
<span class="cat-links">
<?php echo bootstrapBasicCategoriesList($categories_list); ?>
</span>
<?php } // End if categories ?>
<?php
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list(\'\', __(\', \', \'wmillock\'));
if ($tags_list) {
?>
<span class="tags-links">
<?php echo bootstrapBasicTagsList($tags_list); ?>
</span>
<?php } // End if $tags_list ?>
</div><!--.entry-meta-category-tag-->
<?php } // End if \'post\' == get_post_type() ?>
<div class="entry-meta-comment-tools">
<?php if (! post_password_required() && (comments_open() || \'0\' != get_comments_number())) { ?>
<span class="comments-link"><?php bootstrapBasicCommentsPopupLink(); ?></span>
<?php } //endif; ?>
<?php bootstrapBasicEditPostLink(); ?>
</div><!--.entry-meta-comment-tools-->
</footer><!-- .entry-meta -->
SO网友:Krzysiek Dróżdż
答案在您的代码中。甚至有文件记录:
<?php if (is_search()) { // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
<div class="clearfix"></div>
</div><!-- .entry-summary -->
<?php } else { ?>
<div class="entry-content">
<?php the_content(bootstrapBasicMoreLinkText()); ?>
<div class="clearfix"></div>
<?php
/**
* This wp_link_pages option adapt to use bootstrap pagination style.
* The other part of this pager is in inc/template-tags.php function name bootstrapBasicLinkPagesLink() which is called by wp_link_pages_link filter.
*/
wp_link_pages(array(
\'before\' => \'<div class="page-links">\' . __(\'Pages:\', \'wmillock\') . \' <ul class="pagination">\',
\'after\' => \'</ul></div>\',
\'separator\' => \'\'
));
?>
</div><!-- .entry-content -->
<?php } //endif; ?>
评论中明确指出,上面代码第一行中的if语句说明,摘录应该仅用于搜索。
那你该怎么办?您必须修改if中的条件。怎样这取决于你想要实现什么。。。
如果应在搜索和类别中显示,则可以使用:
if (is_search() || is_category())
如果它应该显示在每个帖子列表上,那么您可以使用否定
is_singular()
.
这是完整的list of conditional tags.