Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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