Support » Plugins » Hacks » RSS excerpt issue with Flipboard

  • Bit of an odd one. I create hand crafted excerpts and formatting isn’t an issue. I created a new RSS template just for a Flipboard feed and Flipboard seems to create the excerpt dynamically from the content depending on space. My problem is it formats it as a normal excerpt so strips paragraphs. As a result there are no line breaks / sections just a big chunk of text – if you look at and flick to the first page you’ll see what I mean. It also means that there isn’t a gap between the full stop at the end of one paragraph and the first word of another.

    Is there any way to reintroduce <p> and </p> tags for the excerpt just for the custom feed which has it’s own template and URL. I could add code either within the template which would target the feed directly or via functions.php which would need to target the feed within the code somehow.

    As there is no formatting for the excerpt it would be great if I could insert <p> </p> between each paragraph to create a line of space if possible but just for the excerpt.

    The RSS feed is for a specific purpose so I can get quite bespoke with it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • function wp_trim_excerpt($text) { // Fakes an excerpt if needed
      global $post;
      if ( '' == $text ) {
        $text = get_the_content('');
        $text = apply_filters('the_content', $text);
        $text = str_replace('\]\]\>', ']]>', $text);
        $text = strip_tags($text);
        $excerpt_length = 55;
        $words = explode(' ', $text, $excerpt_length + 1);
        if (count($words)> $excerpt_length) {
          array_push($words, '[...]');
          $text = implode(' ', $words);
    return $text;

    This is the code that generates the excerpt I think although it seems that excerpt length is ignored by Flipboard. Renaming it and adding it to functions.php with the following edit should do the trick:

    $text = strip_tags($text, '<p>');

    but I’m unsure how to target it at the single feed rather than excerpts in general. Found at

    Moderator bcworkz


    You could try using the value of $_SERVER[‘REQUEST_URI’] to decide which version of strip_tags() to use.

    A feed with any HTML is technically invalid, but I suppose if it works go for it. Does it work? I’d be surprised if flipboard didn’t do their own validation and strip out the tags anyway.

    Thank you bcworkz. I’ve added a snippet in to my functions.php because when I delved in to my version of WordPress I think the above code is outdated. This is what I added – does it look coded correctly (not withstanding that it may not work)?:

    //include paragraphs in excerpts
    function skips_strip_all_tags($string, $remove_breaks = false) {
    	$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
    	$string = strip_tags($string, '<p>');
    	if ( $remove_breaks )
    		$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
    	return trim( $string );
    remove_filter('wp_trim_words', 'wp_strip_all_tags');
    add_filter('wp_trim_words', 'skips_strip_all_tags');

    I got to this by looking at the core formatting.php file and tracing through how it seems to create the excerpt. It is exactly the same as the core file with the addition of the <p> tag to this line:

    $string = strip_tags($string, '<p>');

    The reason I think this should in theory work is that when I see other excerpts on Flipboard it seems to respect paragraphs (or line breaks at least – paragraphs are unformatted) but mine just all merge together into a single block. The full post which is gathered from RSS appears to respect many html tags and is nicely formatted – is just the excerpt that’s a problem.

    I can’t say whether it works because I’m not sure how to force Flipboard to re-cache the RSS feed now that it already has it. I find RSS confusing!

    Moderator bcworkz


    Yes, on a cursory look that code should do what you want.
    Not only is RSS confusing, I know little of the inner workings, other than the feed is an XML file.

    I have to wonder if there is something in the RSS schema which allows for paragraph breaks on a formal level, considering HTML tags are invalid. If there is such a thing, that would be the best approach because it would result in completely valid XML.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘RSS excerpt issue with Flipboard’ is closed to new replies.