Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • Jason_9
    Participant

    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.

    Hi 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/f4891252f698a62bb0dc21d040853e7e

    Note that these shortcode parameters will work only in woocommerce products.

    Thanks,
    Aakash

    Jason_9
    Participant

    Absolutely 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.

    Jason_9
    Participant

    Hi 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.

    Hi 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,
    Aakash

    Jason_9
    Participant

    Hi 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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Subscribe for updates

Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam. View newsletter