Grow your CSS skills. Land your dream job.

Last updated on:

Output Excerpt Manually

There is always the_excerpt(), but that does some pretty specific stuff (e.g. adding paragraph tags, adding [...], not respect the more comment, use the saved excerpt...). Advanced Excerpt is pretty good at customizing that.

If you want to get real simple though:

<?php 
  $content = get_the_content(); 
  echo substr(strip_tags($content), 0, 130) . '...'; 
?>

Comments

  1. Permalink to comment#

    Change the … to

    &hellip;

    and you’ve got an even better snippet. 3 dots (periods) is not the same thing as ellipses.

  2. Permalink to comment#

    Instead of substr which may not work in some languages use wp_trim_words function instead.

Leave a Comment

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like this:

```
<div>Example code</div>
```

You don't need to escape code in backticks, Markdown does that for you. If anything screws up, contact us and we can fix it up for you.

*May or may not contain any actual "CSS" or "Tricks".