-
AuthorPosts
-
August 8, 2022 at 3:24 pm #11480Jason_9Participant
Hi – I know this is a basic question, but how would I use Shortcoder to create a shortcode which shows the WooCommerce product long description? I couldn’t see and WC options by default.
Many thanks again for the great plugin.
Your help is appreciated.
August 8, 2022 at 11:38 pm #11483Aakash ChakravarthyKeymasterHi Jason,
WooCommerce shortcode parameters are not included as a part of the plugin.
You can paste the code below to include Woocommerce shortcode parameters.
https://gist.github.com/vaakash/f4891252f698a62bb0dc21d040853e7eNote that these shortcode parameters will work only in woocommerce products.
Thanks,
AakashAugust 9, 2022 at 7:27 am #11486Jason_9ParticipantAbsolutely perfect, this is awesome, thank you.
So, this goes in functions.php, and I can comment out the parameters I don’t need to load? Does this improve performance, etc? eg. if I only need the description, comment out the rest? Thank you again.
August 9, 2022 at 9:49 am #11487Jason_9ParticipantHi Aakash – sorry to reply again but I just went to implement this and I see that the WooCommerce parameter I need isn’t there: the product description (i.e. the long/main description). Could you possibly let me know how to adjust the functions code to include it? I don’t want to break your great code….
Very much appreciated again.
August 9, 2022 at 7:54 pm #11491Aakash ChakravarthyKeymasterHi Jason,
You can use the WordPress information -> “Post excerpt” tag itself.
As of now the plugin is printing only 100 characters.
But you can make the change in the code to print full post excerpt.
In Plugin editor > shortcoder/includes/metadata.php
Replace this
public static function excerpt( $length = 250 ){ global $post; if( !is_object( $post ) ){ return ''; } $excerpt = $post->post_excerpt; // using $post->post_excerpt instead of get_the_excerpt as the_content filter loses shortcode formatting $excerpt_text = ( empty( $excerpt ) ) ? strip_tags( strip_shortcodes( $post->post_content ) ) : $excerpt; return substr( $excerpt_text, 0, $length ); }
with this
public static function excerpt( $length = 250 ){ global $post; if( !is_object( $post ) ){ return ''; } return $post->post_excerpt; }
I’ll make the change in the next version to print the full description.
Thanks,
AakashAugust 12, 2022 at 4:45 am #11504Jason_9ParticipantHi Aakash – thanks again for your reply. Apologies for the delay, I got hit by C19.
Unfortunately, the WordPress Post Excerpt shows the Product Short Description. I need to show the product long description (ie. it is not the excerpt, it is the main product description – the main content field – which usually appears by default in the product tabs under ‘Description’.
How do I go about displaying this via Shortcoder?
Many thanks again.
-
AuthorPosts
- You must be logged in to reply to this topic.