WordPress.org

Support

Support » Themes and Templates » Trimming the excerpt to X words in WP 1.5

Trimming the excerpt to X words in WP 1.5

  • 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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Would the_content_rss() do?

    http://codex.wordpress.org/Template_Tags/the_content_rss

    (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.

    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.

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trimming the excerpt to X words in WP 1.5’ is closed to new replies.