user1444027
user1444027

Reputation: 5251

Post and excerpt

I have the following piece of code which outputs a long article:

<?php the_content(); ?>

I am trying to show only an excerpt of the article (the first 29 words), strip out the HTML and add a "...more" at the end.

<?php substr(the_content, 29) ?>

I have tried this but it has no effect on the length.

Any help? Thanks

Upvotes: 1

Views: 152

Answers (2)

xdazz
xdazz

Reputation: 160953

What you need is the_excerpt

<?php the_excerpt(); ?> //and you could check the doc how to set the length.

Upvotes: 2

Riz
Riz

Reputation: 10246

<?php echo substr(get_the_content(), 0, 29); ?>

the_content prints the content and get_the_content will get that.

Upvotes: 0

Related Questions