Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jeremy Frimond
Jeremy Frimond
14,470 Points

the_exerpt() for custom post types?

I would like to use the_excerpt(); for the content area of a custom post type I have created on a site. currently I am using the_field( 'content' ); for the main page. I would like just an excerpt of the content to show before the person clicks into the single post page.

How do I do this for custom post types?

cheers

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Jeremy,

You can do this two ways.

  1. In your register_post_type function call add the key supports and set the value as an array and inside it add exerpt as an string, or;
  2. Use the add_post_type_support hook and set your post type to support exerpt