Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Robin Cornett

    (@littlerchicken)

    I did some testing with the content from your latest post and the plugin is behaving as intended. That being said, the plugin is more concerned with ending the feed excerpt with a full sentence than with strictly honoring the word count. Therefore, if your 30 words hits in the middle (or at the beginning) of a sentence, the plugin will attempt to complete the sentence, no matter how long it is, or how much longer it makes the excerpt.

    In your most recent post, the first sentence is exactly 30 words (how the computer/plugin counts words), which puts you right on the edge of pulling the second sentence in, which it’s doing. For some reason, the heading tag is being counted as part of the word count as well, which is pushing the result right into the second sentence. I believe that if you drop the count to 25, for example, you’ll see it pull just the first sentence, but I will look into why the heading tag may be being counted, because it should not affect the count.

    Plugin Author Robin Cornett

    (@littlerchicken)

    Sorry, I had it backwards. The heading markup is removed from the count, so with the heading, your first sentence is actually shorter than the 30 words, because normally, the count would include the paragraph tags as part of the markup, and the word count would have been satisfied within the first sentence.

    I think your options are:

    • adjust the word count down to a point where you know you’ll consistently be in your target range.
    • for the most control possible over the descriptions in the feed, use WordPress’ manual excerpt feature, and the plugin will use that in the feed instead of trying to calculate out word counts and sentences. Length won’t matter.
    • another option, which would be a bit more work, would be to modify the markup allowed by the plugin in the excerpt, so that your heading tags would be counted. There is a filter for this, and an example is below.
    add_filter( 'send_images_rss_allowed_tags', 'prefix_add_allowed_tags' );
    function prefix_add_allowed_tags( $tags ) {
    	$tags .= '<h3>';
    	return $tags;
    }

    Hope that helps.

    Thread Starter Paul

    (@wilkymetal)

    Hi Robin,
    Thank you very much for the advice – I think I’m going to go with adding the filter so to include the h3 tags.
    Just to confirm, I add this code to the functions.php?!
    If so, I’ve applied it now and I’ll let you know how it goes!
    Thanks again!

    Thread Starter Paul

    (@wilkymetal)

    Hi Robin,
    Looking at the code again, I’m sure the plugin is having trouble excluding bullet lists.

    If I look at other posts in the feed, all the posts without bullet lists look ok and the posts with bullet lists don’t seem to be rendering the excerpt length.

    Could something like this work?!

    add_filter( 'send_images_rss_allowed_tags', 'prefix_add_allowed_tags' );
    function prefix_add_allowed_tags( $tags ) {
    	$tags .= '<h3>, <ol>, <li>';
    	return $tags;
    }

    Or some other way to include multiple tags in the filter?

    Thanks.

    Plugin Author Robin Cornett

    (@littlerchicken)

    Yes, you can modify the filter like that to include more tags. However, I would still suggest using the manual excerpts for the ultimate control over what your emails will look like.

    Thread Starter Paul

    (@wilkymetal)

    Hi Robin,
    I’m now using the Excerpt function in WordPress BUT, now I get a “Read More” link where I have placed the “Read more tag” on the blog!

    When it goes through my RSS-to-email Mailchimp campaign, I get a “Read More” link, a link that is named the same as the post title and a “Read More” CTA Button module.

    Is it possible you can tell me how to remove the first “Read More” link that looks as if it is coming from the “Read More Tag” within the post?!

    https://www.computamedic.co.uk/blog/ – blog excerpts
    https://www.computamedic.co.uk/feed/rss2/ – Feed link
    https://us2.campaign-archive2.com/?u=682206a04d8b0fe55e7b52f9c&id=4bbadb4d7b&e=34a0c95e95 -RSS-to-email Campaign

    Thank you.

    Plugin Author Robin Cornett

    (@littlerchicken)

    I think these are the two functions causing this in your theme:

    add_filter( 'excerpt_length', 'responsive_excerpt_length' );
    add_filter( 'excerpt_more', 'responsive_auto_excerpt_more' );

    So you’ll want to write a function to remove that on your feed. Something like (untested, please use with caution, practice safe coding, etc.etc.):

    add_action( 'wp_head', 'computamedic_remove_read_more_feed' );
    function computamedic_remove_read_more_feed() {
    	if ( ! is_feed() ) {
    		return;
    	}
    	remove_filter( 'excerpt_length', 'responsive_excerpt_length' );
    	remove_filter( 'excerpt_more', 'responsive_auto_excerpt_more' );
    }

    You might only need to remove the first one, but that’s just guessing. These are in the /responsive-master/core/includes/functions-extras.php file of your theme, as far as I can tell. Again, this code snippet isn’t tested, so please make sure you have a backup in place. You may want to confirm this answer with your theme’s support team, but this should remove the read more bit from the feed, and not your site.

    Thread Starter Paul

    (@wilkymetal)

    Hi Robin,

    I’ve pasted that code into the theme functions.php but it doesn’t seem to be working or having the desired affect.

    However, I did comment out the lines you suggested in the files you suggested – this has worked!

    Thank you very much!

    Thread Starter Paul

    (@wilkymetal)

    Hi Robin,
    Incidentally, how did you find out those particular lines of code were in that location?!

    Thank you.

    Plugin Author Robin Cornett

    (@littlerchicken)

    Glad you got it sorted–if you feel like experimenting, you could try setting the is_feed() conditional in the theme functions, instead of commenting them out, if you want the auto read more back. It may take some tinkering, but should be doable.

    Finding the code took a bit of detective work–I downloaded the theme from Github, and searched the theme files for excerpt related functions. Thanks for letting me know how it worked out!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Excerpt length at 30 words isn't working’ is closed to new replies.