Trying to modify content.php

时间:2019-03-16 作者:Gary

我正在尝试调整引导程序的基本主题,以便它显示摘录。它在使用搜索时执行此操作,但在默认情况下不执行此操作。

我正在试图找出我需要对内容进行哪些更改。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 -->

1 个回复
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.

相关推荐

如何在重定向wp-login.php的同时仍允许注销和其他操作?

我的目标:重定向前往wp登录的访问者。php(或尝试注册的用户)访问主页。但仍允许wp登录。php在注销、丢失密码和重置密码等特定操作期间运行。我们在另一个问题中使用了代码,使我们几乎达到了目标。(How to use wp-login.php page only for logout?) 我们的修改添加了lostpassword和密码重置操作。这就是我们现在所拥有的:// Allow logout and lost password actions but redirect to the home pa