Expand/Shrink toggle on truncate

enter image description here

So I’m attempting to truncate using the wp_trim_words action and I’m able to successfully trim the words, but how would I be able to revert wp_trim_words on a toggle to shown the full text if it’s clicked?

Here is what I have:

    .truncate {
        /*white-space: nowrap;*/
        /*overflow: hidden;*/
        /*text-overflow: ellipsis;*/

    function RevealHiddenOverflow(d) {

<section id="gallery">
    <div class="container">
        <div id="image-gallery">
            <div class="row">
                <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12 image">
                    <div class="img-wrapper">
                        <?php if(!empty($images->data)):
                                foreach ($images->data as $image) : ?>
                                        <a style="border-bottom: none" href="<?= $image->permalink ?>" target="_blank"><img src="<?= $image->thumbnail_url ?: $image->media_url; ?>" alt="" class="img-responsive"></a>
                                        <p class="truncate" onclick="RevealHiddenOverflow(this)" style="text-align: center"><?= wp_trim_words('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum', 10, '...') ?></p>
                                    <?php endforeach; ?>
                                <p class="section-link" style="text-align: center"><a href="https://www.instagram.com/<?= $image->username ?>" target="_blank">View More</a></p>
                                echo 'No posts available.';
                        endif; ?>

Read more here:: Expand/Shrink toggle on truncate

Leave a Reply

Your email address will not be published. Required fields are marked *