-
AuthorPosts
-
October 31, 2016 at 7:43 pm #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?
November 2, 2016 at 4:05 pm #707191Hey zimbo,
I can’t find the product in question on the link you’ve provided. Can you check please?
Best regards,
AndyNovember 2, 2016 at 4:45 pm #707224Hi,
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.
November 4, 2016 at 2:33 pm #708185Hi,
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,
AndyNovember 4, 2016 at 3:26 pm #708225Hi,
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 8 years ago by zimbo.
November 4, 2016 at 3:42 pm #708246Hi,
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,
AndyNovember 4, 2016 at 4:30 pm #708305The 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…?
November 4, 2016 at 4:43 pm #708319Hi,
Please create a temporary admin login and FTP logins and post them here privately :)
Best regards,
YigitNovember 4, 2016 at 7:39 pm #708398In private below as requested. Whilst this dev… site is obviously live it is only used for test & development and is hidden from search engines.
November 7, 2016 at 1:54 pm #709181Hi,
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 websiteBest regards,
YigitNovember 7, 2016 at 2:28 pm #709207Hi 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?
November 8, 2016 at 6:59 am #709619Hi!
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,
IsmaelNovember 9, 2016 at 5:13 pm #710331Well, 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?
November 10, 2016 at 2:48 pm #710724 -
AuthorPosts
- The topic ‘Woocommerce Short Description not displaying correctly on category page’ is closed to new replies.