Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Excerpts


salemw
Member

@salemw

Well my friend found a solution for me and in case I wasn’t the only one asking for excerpt RSS

here it is:

Add this function to functions.bb-template:

// excerpt for rss
function post_text_excerpt( $post_id = 0 ) {
echo apply_filters( 'post_text', get_post_text_excerpt( $post_id ), get_post_id( $post_id ) );
}

function get_post_text_excerpt( $post_id = 0 ) {
$bb_post = bb_get_post( get_post_id( $post_id ) );
// Number max of characters
$max_rss=250;
$excerpt_rss = $bb_post->post_text;

if (strlen($excerpt_rss)>$max_rss) {
$excerpt_rss = substr(ltrim($excerpt_rss), 0, $max_rss);
preg_match('<code>.+(?=[,;.])</code>s', $excerpt_rss, $out1);
preg_match('<code>.+(?=[ ])</code>s', $excerpt_rss, $out2);
if ( ( strlen($out2[0]) - strlen($out1[0]) ) < $tronque_maxi) {
$excerpt_rss = $out1[0];
} else {
$excerpt_rss = $out2[0];
}
if (preg_match('<code>.+(?=(de|du|dans|le|la|a|à)$)</code>s', $excerpt_rss, $out3)) {$excerpt_rss = $out3[0];};
return $excerpt_rss."...";
} else {
return $excerpt_rss;
}
return apply_filters( 'get_post_text', $excerpt_rss, $bb_post->post_id );
}
// end excerpt for rss

And replace post_text() par post_text_excerpt() in my-templates/your_template/rss2.php

The author website:

http://messouvenirs.net/

Skip to toolbar