2

I have a WordPress installation that sometimes uses long and lengthy posts delimited by the <!--more--> tag. However on my RSS feeds, the entire post is shown.

Is there a way, aside from custom tags, to delimit how much is shown in a WordPress Feed or just show enough until the "More" tag?

4

You can select between Full text and Summary in the Reading settings:

settings menu

settings

If you select the Summary, then

a) To control the number of words in the feed summary you can use:

add_filter('excerpt_length','custom_excerpt_length'); 
function custom_excerpt_length( $num_words ){
    return 30; // number of words to show
}

The default number of words in the summary is 55.

b) If you want to use <!--more--> in the post content to define the feed summary, you can use the following:

add_filter( 'the_content', 'custom_content_feed' );
function custom_content_feed( $content ){
    if( is_feed() ){
        // <!--more--> used in the post content: 
        if( strpos( $content, '<span id="more-') !== FALSE ){
            // remove the excerpt length limit
            add_filter( 'excerpt_length', 'custom_long_excerpt_length' ); 
            // get the content before <!--more-->
            $content = stristr( $content, '<span id="more-', TRUE );
            // add the default 'read more' symbols at the end:
            $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[&hellip;]' );
            $content .= $excerpt_more;
         }
    }
    return $content;
}
function custom_long_excerpt_length( $num_words ){
    return 99999;
}

c) You can also use a) and b) together.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.