Trimming the excerpt to X words in WP 1.5 (4 posts)

  1. randyhoyt
    Posted 11 years ago #

    I want to have excerpts on my home page instead of the full text. I have found many posts on using the_excerpt(). But I want it to create an excerpt based on the body where I can limit the number of words and strip out the HTML.

    I could do this in 1.2 using the_excerpt_rss(cut, html_encoding) function, but these parameters no longer seem to work. Does anyone have any suggestions?

  2. Kafkaesqui

    Posted 11 years ago #

    Would the_content_rss() do?


    (Not sure why they dropped the arguments from the_excerpt_rss(). Yet another Codex edit...)

    For further control, check out my plugin the_excerpt_Reloaded.

  3. randyhoyt
    Posted 11 years ago #

    Thanks for the link to your plugin ... that did the trick.

    I would recommend one small change to the plugin. Let's say I had an excerpt with HTML in it (different than the cotent), but I decided that on the home page I wanted to strip the HTML out of it. I tried the_excerpt_reloaded('40', '', '2') -- where the '2' means strip out the HTML -- and yet it still showed the HTML. That's because your script will only strip out the HTML if you don't have a value in the excerpt field.

    I would recommend moving line 87 ... [ } // end if no excerpt ] ... up to line 67. That way, it will perform all the operations requested in the parameters even if you have something in the excerpt field -- this seems like the more intuitive behavior.

  4. Kafkaesqui

    Posted 11 years ago #

    Thanks for the feedback. And I agree, it should perform the strip under either condition.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.