$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>excerpt - Trying to modify content.php|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

excerpt - Trying to modify content.php

matteradmin9PV0评论

I am trying to tweak the bootstrap basic theme so that it shows excerpts. It does it when using search but not by default.

I am trying to figure out what I need to change on the content.php file. Could someone please advise.

I have been trying for hours and am struggling. Code below:

<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 -->

I am trying to tweak the bootstrap basic theme so that it shows excerpts. It does it when using search but not by default.

I am trying to figure out what I need to change on the content.php file. Could someone please advise.

I have been trying for hours and am struggling. Code below:

<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 -->

Share Improve this question edited Mar 16, 2019 at 6:15 butlerblog 5,1413 gold badges28 silver badges44 bronze badges asked Mar 16, 2019 at 2:06 GaryGary 91 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

The answer is in your code. It’s even documented:

<?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; ?> 

There is clearly stated in the comment, that the if statement in the first line of code above is telling, that the excerpt should be shown only for search.

So what do you have to do? You have to modify the condition inside that if. How? It depends on what do you want to achieve...

If it should be shown on search and categories, you can use:

if (is_search() || is_category())

If it should be shown on every list of posts, then you can use negation of is_singular().

Here’s the full list of conditional tags.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far