Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #706444

    Please see this post/product.

    The Short Description is written out on the product page as

    Limited Edition Print
    Giclee
    Published in 2016
    Supplied mounted

    and that is how it displays on the above product page.

    If I look at the Text version of the words (as opposed to Visual) there are no HTML Tags but on the rendered page there are <p> … </p> tags around each line so each displays on its own line – which is how it should be.

    I have implemented the code below in functions.php to show the Short Description on the category summary page as seen here (scroll down/search for the Anniversary Waltz product, it’s the only one with a Short Desc) or there’s a screenshot here.

    add_action( 'woocommerce_after_shop_loop_item_title', 'avia_shop_overview_extra_header_div_new', 20);
    function avia_shop_overview_extra_header_div_new() {
    	global $post;
    	$text = '<div>' .$post->post_excerpt. '</div>';
    	echo $text;
    }

    The Short Desc is appearing on the product thumbnail but the formatting is not correct. As you can see the text lines are not separated because no <p> or <br> tags are being inserted, and the 4 lines show one after another. If I try to manually insert a <p> in the Text editor, the WordPress editor strips them out again.

    How can I get the Short Description to display properly on the category page i.e. each line on its own, as it does on the product page?

    #707191

    Hey zimbo,

    I can’t find the product in question on the link you’ve provided. Can you check please?

    Best regards,
    Andy

    #707224

    Hi,

    The product I’ve added the Short Description to is Anniversary Waltz, URL http://dev.jacksgallery.co.uk/product/anniversary-waltz/

    On the limited-edition-prints product category page you may need to adjust the ‘Sort by’ selector for ‘Name’, then that product should appear in the middle of the second row on the first page.

    #708185

    Hi,

    I can’t find any sort by slector on the link you’ve provided. This is quite confusing for me.

    This is what I see: http://i.imgur.com/EYFBJVm.jpg

    Best regards,
    Andy

    #708225

    Hi,

    You need to look at 2 things.

    1. The product listing for Anniversary Waltz as per your imgur image. The Short Description is listed out one line after another. This is OK.

    2. Then look at the thumbnail/summary for that product on the category page for Limited Edition Prints, as seen in my link here: http://imgur.com/a/GnzpS. (The menu structure has changed; the category page URL is – http://dev.jacksgallery.co.uk/product-category/limited-edition-prints/) To easily find the thumbnail/summary for the product Anniversary Waltz on the category page you should alter the “Sort by…” selector at the top of the page to “Sort by Name”, then the thumbnail should appear in the middle of the second row on the first page. When you see the thumbnail you will see the Short Description lines flow one after another and are not separated by line breaks as they are in the actual product, so this is wrong. This is what you can see in my imgur link above.

    • This reply was modified 7 years, 5 months ago by zimbo.
    #708246

    Hi,

    as far as I can see it there is no easy possibility to add some css code to style it, as it’s a standard div element, without any class. As it’s a WooCommerce function, I would ask WooCommerce support about it. This is nothing which the theme controls. So hopefully they have a solution for you available.

    Best regards,
    Andy

    #708305

    The function to get the Short Description to display on the category thumbnail viz.

    add_action( 'woocommerce_after_shop_loop_item_title', 'avia_shop_overview_extra_header_div_new', 20);
    function avia_shop_overview_extra_header_div_new() {
    	global $post;
    	$text = '<div>' .$post->post_excerpt. '</div>';
    	echo $text;
    }

    was actually provided by Yigit, one of your Enfold Support colleagues, in response to a previous question – https://kriesi.at/support/topic/woocommerce-grid-remove-price-and-add-product-short-description-instead/#post-680083

    I have modified that function by using snippets from other Enfold questions/replies to get it to show the Short Description instead of the_excerpt, so I rather hoping that someone could suggest a further tweak to fix how the Short Description is currently being displayed…?

    #708319

    Hi,

    Please create a temporary admin login and FTP logins and post them here privately :)

    Best regards,
    Yigit

    #708398

    In private below as requested. Whilst this dev… site is obviously live it is only used for test & development and is hidden from search engines.

    #709181

    Hi,

    By default, WordPress strips out HTML tags from excerpts. The most convenient solution i came up with is adding short descriptions in text tab using HTML tags.
    Please review your website

    Best regards,
    Yigit

    #709207

    Hi Yigit,

    I tried to add HTML tags in Text previously but found the editor stripped them out. When I viewed the Text tab of the Short Description that you had edited, this is what I saw on screen: http://imgur.com/a/Wz3F9 – there were no HTML tags.

    And as soon as I did an Update on the product, your edits were lost. How did you get the <p> and <br> tags to stay?

    #709619

    Hi!

    The editor automatically strips those tags. However, it will be automatically added later in the frontend if necessary. If you really want to use those tags in the editor, add a class attribute to it. Example:

    <p class="custom_p">CONTENT HERE</p>
    <br class="custom_br"/>
    <p class="custom_p">CONTENT HERE</p>
    

    Best regards,
    Ismael

    #710331

    Well, I found another way to get this working.

    I found the code section where WooCommerce displays the Short Desc on the product and used that, as so:

    add_action( 'woocommerce_after_shop_loop_item_title', 'avia_category_page_new_div', 20);
    
    function avia_category_page_new_div() {
    	global $post;
    	$desc = '<div class="category-desc">' .apply_filters( 'woocommerce_short_description', $post->post_excerpt ). '</div>';
    	echo $desc;
    	
    	global $product;
    	echo $product->list_attributes();
    }

    I’ve also added in the Attributes as well so the client can decide which one (or both) they want. It works so I assume this is a valid way of doing this?

    #710724

    Hi,

    Your solution looks fine. Thank you for sharing!
    Let us know if you have any other questions or issues!

    Best regards,
    Yigit

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Woocommerce Short Description not displaying correctly on category page’ is closed to new replies.