But I don't have any actual text in excerpts. I thought it would make the excerpt dynamically but it doesn't. So instead, how do I use this code to apply to the post content instead of the excerpt? So:
[wpv-conditional if="('[cust_count_chars text='wpv-post-excerpt]' gt '100' ) "] Do this [/wpv-conditional]
to instead be this:
[wpv-conditional if="('[cust_count_chars text='wpv-post-body]' gt '100' ) "] Do this [/wpv-conditional]
I tried that last piece of code but it doesn't do anything. Do I need to adjust the shortcode you sent?
Thanks. I tried that but it doesn't seem to work. All my posts are greater than 100 characters and yet it doesn't show anything. If I put instead:
[wpv-conditional if="('[cust_count_chars text='[wpv-post-body]']' lt '1' ) "] Do this [/wpv-conditional]
Then "Do This" shows in every post ( I changed gt to lt and the number to 1). So it seems like it is not counting any actual characters. It's like it sees them all have 0 characters so if I use lt, it always shows that piece of text. If I use gt, it doesn't.
Thanks for this. I fixed the login issue. I put in the new code but it doesn't seem accurate at all. For instance, It thinks this announcement:
"We will be hosting a blood drive! Time slots available from 12:00 until 3 pm. Register online today or email erin@placec.org if you have questions. "
is more than 300 characters. Yet the announcement below that is longer and it thinks it has less than 300 characters. You can see on that announcement page.
It also thinks content with JUST an image inserted is more than 300 characters (see last announcement on that page).
Can you take a look? I think we are closer but not quite there.
There will be inaccuracies with this mainly because you are doing it on the post content which can have images, texts pretty much any kind of content and the function that we are using is counting the string length. For images i'm not sure how the strlen() php function process this.
Regarding the ones with just texts only I'm seeing that the counts are actually correct.
The code that you should be using is this one below.
[wpv-conditional if="('[cust_count_chars id='[wpv-post-id]']' lt '300' ) " ] Post ID: Less than 300 [/wpv-conditional]
[wpv-conditional if="('[cust_count_chars id='[wpv-post-id]']' gt '300' ) "] Post ID: Greater than 300 [/wpv-conditional]
I assume then there is no way to count rendered characters instead? Ultimately I'm trying to show the actual body text as the announcement when it's shorter than 300 characters, since the body shows rendered html.
The best thing that can be done here, is to perform a string length with the html content stripped from the text because html characters add to the length of the string.
There isn't an efficient way to count the character length when we have no control over the content that can be added to the field.
Given that this is custom code there isn't much else that I can do to resolve this.