I am using the following to shorten the excerpt if it exceeds a certain amount of characters, whilst also not cutting the last word.

```html
ob_start();
the_excerpt();
$excerpt = ob_get_clean();

 if (strlen($excerpt) < 200) {
      echo $excerpt;
        } else {
            $new = wordwrap($excerpt, 200);
            $new = explode("\n", $new);

            $new = $new[0] . '...';

            echo $new;
        }
```

The problem is that this only works if an excerpt is set, if not the excerpt only displays the first line or first sentence - see photo. I understand that the\_excerpt pulls the\_content if no excerpt is present, but do not understand why the wordwrap doesnt work properly when content is used instead of the excerpt?

[![The first two images have no excerpt last one has](https://i.stack.imgur.com/1Y6gC.png)](https://i.stack.imgur.com/1Y6gC.png)