Tell us what you are trying to do?
Take the first 150 words of body text, and not with the standard WP Text Excerpt which is used already. I have a custom field called introduction which will be added to the view template of the custom post type. When this custom field introduction is empty, I want to display the first 150 words.
Hi Shane, many thanks for your help. I've added the code to trim the body content provided by your customer but as soon as I add the shortcode [limit_content length="280"], the view doesn't load anymore.
Both the snippets for trimming with char counts and char counts without white spaces fail.
I've also tried adding the shortcode in a normal blog post and the post can't even be saved.
Hi Shane, there's no page or post for that because once the short code is inserted, the page or post just doesn't save. The same also happens if i try to put the short code into a content template view.
It'd be great if this could be solved, otherwise, I'll just go ahead without a custom "excerpt".
Quite odd, I did a quick test of the shortcode at the link below. hidden link
I've added the custom shortcode to the content template below. hidden link
As you can see at the bottom i've added a conditional block that is checking if the intro custom field is empty and then displaying the contents of the block if it is empty.
What I did was to temporarily remove the field data and then refresh the post on the frontend and it works fine. If there is a specific context that you want to use the shortcode in please let me know.
Though, it's rather strange: i tried to access hidden link (this is the template for CPT projekt)
and i get "critical err", please see attached screenshot.
Since i can't open the content template for CPT projekt, i think it's probably better, if i don't use the shortcode.
I'm reverting the view template and go ahead without the custom excerpt.
Maybe you want to look into this matter should that also happen to others.
I'm going to close this ticket since i'm not going to use the conditional to check and take the first 150 words of body text.