Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1487337

    Dear people on the support forum,

    I am creating a website on this domain:

    Here, I have 2 sections with post sliders in a 3-column layout. Right now, the featured image, title and read more link are linked to the full article.
    Is there a way to make the entire excerpt column clickable?

    Your help will be highly appreciated!

    #1487372

    Hey pelgrimrat,

    Thank you for the inquiry.

    You can add this code in the functions.php file to make the excerpt clickable with the same link as the title and featured image.

    function ava_custom_script_mod() {
        ?>
        <script>
        // make post grid excerpt clickable
        jQuery(document).ready(function($) {
            $('article.slide-entry').each(function() {
                const $article = $(this);
                const link = $article.find('a.slide-image').attr('href');
    
                if (link) {
                    const $excerpt = $article.find('.slide-entry-excerpt');
    
                    $excerpt.css('cursor', 'pointer').on('click', function(e) {
                        if (!$(e.target).closest('a').length) {
                            window.location.href = link;
                        }
                    });
                }
            });
        });
        </script>
        <?php
    }
    add_action( 'wp_footer', 'ava_custom_script_mod', 9999 );
    

    Let us know the result.

    Best regards,
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.