0
votes

I'm trying to modify the existing wordpress woocommerce single product shortcode, (ie: [product id="2020"]

This shortcode will display the product by id and description.

My goal is to use a modified shortcode on a normal "page" & display the product with gallery (and it's thumbnails) as it would display per single product page.

Image

1
You could create your own shortcode man, You shouldn't modify a plugin directly because if it updates your codes will be lost. If you know the basic construct of a shortcode you could just use this the_content and get_the_title. That way you will get the title and description of the product.rai nalasa
Thank you rai, thank you for pointing me in the right direction. I have much to learn, MUCH to learn. I am a novice but I will try.Val Mocan
gave an answer on how to use it.rai nalasa

1 Answers

0
votes
function show_my_product_callback($atts)
{
    $a = shortcode_atts(array( 
        'product_id' => ''),$atts );

    echo get_the_title($a['product_id']);
    echo get_the_content($a['product_id']);
}

add_shortcode( 'show_my_product', 'show_my_product_callback' );

on using it: [show_my_product product_id='3']

more reading resources.

get_post_meta - for the custom fields.

get_post_content - for the product description.

get_the_title - for the name of the product.