Show excerpt of author bio in vendors page

Hello there,
In the listings page, I would like to show only a part (substring) of the vendor description, together with attributes.
For the moment, All I could managed to do is add an extra attribute, but the value already in the vendor profile (bio), so why duplicate it ? It’s awkward.

Please advise. I am stuck.

Here’s the solution I found out.
It seems I have to “game” the system all the time, for lack of support, or personal knowledge.

So I copy the first nth characters of the vendor’s description in the excerpt text field, whenever this field is left empty.

jQuery(document).ready(function($) {
    // Listen for the form submission
    $('form').on('submit', function(event) {
        // Select the accroche and description fields
        const $accroche = $(this).find('input[name="accroche"]');
        const $description = $(this).find('textarea[name="description"]');

        // Check if the accroche field is empty
        if ($accroche.val().trim() === '') {
            // Get the first 100 characters from the description field
            const descriptionText = $description.val().trim();
            const accrocheText = descriptionText.substring(0, 85);

            // Set the accroche field's value if description has content
            if (accrocheText.length > 0) {
                $accroche.val(accrocheText);
            }
        }
    });
});

Cheers !

Please try using this PHP snippet instead How to display vendor description in item page? - #2 by yevhen It embeds vendor bio into the vendor block without an extra attribute, it also doesn’t require extra JS/CSS.

You can adjust ‘_order’ to move the embedded description, or replace 'content' => $vendor->display_description(), with 'content' => substr($vendor->get_description(),0,123), to trim the text.

Hope this helps

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.