First part of the post blah blah … Read more Read more >>
There were 2 Read more links at the end, but only the final one “Read more >>” had the link on it. When I disabled the option on your plugin to not display the Read More link, the last “Read More >>” disappeared, but the first one without the link remained.
Looking more into it, I think the problem is the use of the wp_trim_words function which apparently strips all tags from the trimmed text, hence losing the “a” tag.
I have currently worked around the problem by doing the following – replaced the following line in recent-posts-widget-extended/includes/functions.php:
Original:
$html .= wp_trim_words( apply_filters( 'rpwe_excerpt', get_the_excerpt() ), $args['length'], ' …' );
Replaced with:
$html .= get_the_excerpt(); // Modified from original
The downside of this is that the excerpt length setting on your plugin basically has no effect any more, but the default length of 55 suits me just fine for now.
Ideally I don’t want to make any changes to your plugin code, so if you’re able to fix the bug in the next version, that would be fantastic. I would suggest – don’t use wp_trim_words and do it all in your own code.
https://www.ads-software.com/plugins/recent-posts-widget-extended/
]]><?php $content = get_the_content(); $trimmed_content = wp_trim_words( $content, 35, ‘ …Read More‘ ); echo $trimmed_content; ?>
I checked the Codex and this seems to be copied right from the example, and I can’t see anything wrong with it. The parameters aren’t being declared and assigned within the function arguments, but I don’t think that’s the problem (tried that already).
However, in practice, the output of the page looks nothing like expected. Instead of 35 words I’m getting 100, and instead of a “Read More” link I’m getting the “[…]” characters.
N.B. I’m using a child theme, but page-home.php is not one of the customised files. I have tried pulling over a customised copy of the file to the child theme, but the problem still persists.
Any ideas where I might look?
(Site URL is https://www.thrifterrific.com/)
]]>the_author_meta('description', 3)
(3 being one of the author ID’s.) I have a feeling it’s just a matter of nesting PHP however I’m not sure how.
Thoughts? Thanks!
<?php $field = 'this text does get trimmed'; $trimmedfield = wp_trim_words( $field, $num_words = 1, $more = '<a href="'. get_permalink() .'"> ...Read More</a>' ); echo '<p>' . $trimmedfield . '</p>'; ?>
I edit content.php to make my entry showing excerpt 40 words for normal post and 65 words for sticky post. So I use wp_trim_words
This is the code,
<div class="entry-summary">
<?php
$content = get_the_content();
$trimmed_content = wp_trim_words( $content, 40, '...<div class="readmoretag"><a href="'. get_permalink() .'">continue reading</a></div>' );
echo $trimmed_content;
?>
</div><!-- .entry-summary -->
But now my website is showing because in my post, I put image with caption in the first paragraph.
How can I remove the caption and only show text paragraph on the excerpt?
]]>I’m trying to add content from a page using the following code
<div class="right-news">
<?php wp_trim_words( the_content, $num_words = 20, $more = null ); ?>
</div>
I cannot use the_excerpt as I’ve set a length for this elsewhere of 8 words.
I want to show the first 20 words of the content in this particular area, but the code used above isn’t working.
Anyone spot the error?
Thanks
dvent