does anybody see anything wrong with the code? It's not showing the excerpts. It it is supposed to show the first 55 words of the content.

The site is this one.

And this is the code:

<article id="post-<?php the_ID(); ?>" <?php post_class('post__holder'); ?>>
        <?php if(!is_singular()) : ?>
        <header class="post-header">
            <?php if(is_sticky()) : ?>
                <h5 class="post-label"><?php echo theme_locals("featured");?></h5>
            <?php endif; ?>
            <h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
        </header>
        <?php endif; ?>
        <?php get_template_part('includes/post-formats/post-thumb'); ?>

        <?php if ( !is_singular() ) : ?>
        <!-- Post Content -->
        <div class="post_content">
            <?php
                if (of_get_option('post_excerpt')=="true" || of_get_option('post_excerpt')=='') { ?>
                    <div class="excerpt">
                    <?php

                    if (has_excerpt()) {
                        the_excerpt();
                    } else {
                        if (!is_search()) {
                            $content = get_the_content();
                            echo apply_filters( 'cherry_standard_post_content_list', wp_trim_words( $content, 55 ) );
                        } else {
                            $excerpt = get_the_excerpt();
                            echo apply_filters( 'cherry_standard_post_content_search', wp_trim_words( $excerpt, 55 ) );
                        }
                    } ?>
                </div>
            <?php }
                $button_text = of_get_option('blog_button_text') ? apply_filters( 'cherry_text_translate', of_get_option('blog_button_text'), 'blog_button_text' ) : theme_locals("read_more") ;
            ?>
            <a href="<?php the_permalink() ?>" class="btn btn-primary"><?php echo $button_text; ?></a>
            <div class="clear"></div>
            <?php if ( function_exists('yoast_breadcrumb') ) {yoast_breadcrumb('<p id="breadcrumbs">','</p>');} ?>
        </div>

        <?php else :?>
        <!-- Post Content -->
        <div class="post_content">
            <?php the_content(''); ?>
            <div class="clear"></div>
            <?php if ( function_exists('yoast_breadcrumb') ) {yoast_breadcrumb('<p id="breadcrumbs">','</p>');} ?>
        </div>
        <!-- //Post Content -->
        <?php endif; ?>

        <?php get_template_part('includes/post-formats/post-meta'); ?>

</article>

In the settings "For each article in a feed, show" is set to "summary". In the Cherry options, also it is set to show an excerpt.

The last article (the one in the top has an excerpt configured in post editing mode, and it's not showing either).

After I received the first answer below, I changed the code to:

<?php

                    if (has_excerpt()) {
                        the_excerpt();
                    } else {
                        if (!is_search()) {
                            $content = get_the_content();
                            echo apply_filters( 'cherry_standard_post_content_list', wp_trim_words( $content, 55 ) );
                        } else {
                            $excerpt = get_the_content();
                            echo apply_filters( 'cherry_standard_post_content_search', wp_trim_words( $excerpt, 55 ) );
                        }
                    } ?>

But it's not showing anything below the pictures. No changes. I think the problem is somewhere else. So I changed it back to $excerpt = get_the_excerpt();

Thank you in advance

  • What's in 'cherry_standard_post_content_search' - does it return anything? – anmari Dec 7 at 7:06
  • How to test that? I've searched cherry_standard_post_content_search in all *.php files in my theme and child themes as well as in the original theme (not edited by me), and it appears only in that file.That's strange... don't know what to do. – Pikk Dec 7 at 8:04
  • Well if you didn't create and don't want it. Then try skipping it. Maybe just: echo wp_trim_words( $excerpt, 55 ) ; – anmari Dec 7 at 9:21

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.