Black Friday: Up to 40% off all plans!

Offer automatically applied at checkout
Days
Hours
Minutes
Seconds

FAQs

Find answers to common questions and step-by-step solutions.

Glossary

An alphabetical list of terms and their definitions.​

Video Library

Discover our tutorials

Filter: When Using Word Trimming, Import Missing Tags in the Post Content

Note: These documents refer to features and updates in the upcoming v5 release, which will be available soon. Some information may not apply to earlier versions. Stay tuned for the official launch announcement!

IN THIS ARTICLE
Learn how to retain essential tags when using the “Trim the content” option in your source’s settings.
Contents

When using the “Trim the content” option in a source’s Advanced > Content settings, some elements of the original content might get excluded from the import if they appear after the end of the word limit you’ve set. You can add the below filter if you’d like to be able to keep the missing tags when using word trimming. 

This example uses the  <img>  element as an example. In cases when the images are stripped from the content after it is trimmed, this will ensure they are all imported while still obeying the word limit.

add_filter('wprss_ftp_trimming_keep_tags', function($tags) {
        $tags = array_merge($tags, array('img'));
        $tags = array_flip($tags);
        $tags = array_keys($tags);
        
        return $tags;
});

How It Works

The “Trim the content” feature works by removing all tags, trimming what is left of the content, and then adding the tags back. This ensures that content doesn’t get trimmed in the middle of a tag, thus breaking the HTML, and that only actual text gets counted toward the word limit you’ve set. When adding the tags back into the content, however, not all tags are processed.

By default, the tags that get added back are the following:  <p>, <br>, <em>, <strong>, <a>, <code> .

This is deliberate and is done to improve security. This list may be changed via the wprss_ftp_trimming_keep_tags filter as shown above.

Learn how to add custom actions and filters to your site.

GIVE FEEDBACK

Was this article helpful?

Still stuck?

Find Your Perfect Plan

Answer a few questions, and we’ll recommend the best option for you!