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>',
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.