Support

Account

Home Forums General Issues "Read more" in ACF text or wysiwyg field Reply To: "Read more" in ACF text or wysiwyg field

  • Hello Everyone, I was facing the same issue, trying to include a read-more button on a textarea field, I tried to switch it to wysiwyg and then create the read more, but it created unwanted p tag. I use javascript-plugin oriented solution instead and not a PHP/Wordpress oriented solution.

    i’m using this Readmore.js plugin
    https://github.com/jedfoster/Readmore.js/tree/version-3.0

    Which we can configure with 2 steps:
    1 – adding specific class to the the field we want to add the read more (textearea in my case)
    2 – write the script for the readmore-js to work

    // My selector where my textarea field is included
    const readMoreParagraphs = document.querySelectorAll('.item-texte');
    
    new Readmore( readMoreParagraphs, {
        speed: 200,
        collapseHeight: 20,
        lessLink: '<a href="#" class="read-more">Read less</a>',
        heightMargin: 16,
        moreLink: '<a href="#" class="read-more">Read more</a>',
    });