Skip Navigation

[Résolu] Conditional based on [wpv-post-body] height

This support ticket is created Il y a 6 années et 11 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par toolset-dave Il y a 6 années et 11 mois.

Assisté par: Luo Yang.

Auteur
Publications
#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: lien caché This is OK: lien caché
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:
lien caché

#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;
}