• Resolved Patrick

    (@zunichi)


    Hi! How can I keep the line breaks in the product short description when shown in the archive page?

    Also, is it possible to limit how many lines are shown, instead of character count? Thank you.

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    This is more of a WordPress question than WooCommerce one since the Short Description essentially makes use of the post excerpt function which, in turn, strip all HTML tags upon saving.

    The following resources should help with that:

    Thread Starter Patrick

    (@zunichi)

    Thank you. I will give this a read and update this post.

    Thread Starter Patrick

    (@zunichi)

    I finally got it to work. Details below for those in the same situation:

    SITE: https://dev.lowyusa.com/
    THEME: OceanWP (Child Theme Activated)
    WORDPRESS: v5.2.1
    ASSOCIATED PLUGIN: WooCommerce
    ISSUE: HTML tags (ul, li, br, etc.) are not allowed in product short description (aka product excerpt) as shown in product archives. OceanWP uses its own custom excerpts so excerpt plugins (such as Advanced Excerpts) do not work.
    SOLUTION: Created a PHP function that pulls the post excerpt before it gets filtered and hooked it to an existing hook in the theme. I then placed it in the functions.php file of the child theme.

    CODE:

    function new_short_desc() {
    	echo '<li class="woo-desc">';
    		global $post;
    		echo strip_shortcodes( the_excerpt() );
    	echo '</li>';
    }
    add_filter( 'ocean_after_archive_product_categories', 'new_short_desc' );
    • This reply was modified 5 years, 9 months ago by Patrick.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Keep line breaks in product short description (and limit lines shown)’ is closed to new replies.