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
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
You're looking at the code wrong. If there is an excerpt it's not going to affect that line you changed. Are you actually entering text into the excerpt field in the post edit?
try changing it to this to see if it's even working:
if (!is_search()) {
echo get_the_content();
} else {
echo get_the_content();
}
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 Commented Dec 7, 2018 at 8:04