Skip Navigation

[Resolved] Conditional based on [wpv-post-body] height

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by toolset-dave 7 years ago.

Assisted by: Luo Yang.

Author
Posts
#598887

Hi, I have a nicely working fade container, but I would like to use it conditionaly only where it is neccesary for [wpv-post-body]. For example I want to disable it here: hidden link This is OK: hidden link
I am not sure what to use as a conditional. Height of [wpv-post-body]? Rows of [wpv-post-body] and is it even possible? Length of [wpv-post-body]? Or anything else, which would work responsible?

<div id="fade-container">
  <div id="fade-content">
    [wpv-post-body view_template="None"]
    <div class="fade-anchor">
      <span class="fade-anchor-text">ZOBRAZIT VÍCE...</span>
    </div>
  </div>
</div>
<script>
$('.fade-anchor').click(function(e) {
  e.preventDefault();

  $('#fade-content').css('max-height', 'none');
  $('.fade-anchor').remove();
});
</script>
#599161

Dear Dave,

There isn't such a built-in feature within Toolset, any workaround for the Height, row or length of [wpv-post-body] will involve custom codes, but according to our support policy we don't provide custom codes support.

Here are my suggestions:
You can create a custom shortcode for it:
https://codex.wordpress.org/Function_Reference/add_shortcode

In this shortcode, get the post content of current post:
https://codex.wordpress.org/Function_Reference/get_the_content

Then count the length of post content:
hidden link

#599260

Hi Luo,

I have created custom function by your help. Thank you, it works nice. If anyone need the same:

add_shortcode('postbodylength', 'postbody_length');
function postbody_length() {
    $post_body = get_the_content();
    $length_count = mb_strlen($post_body);
    return $length_count;
}