• Resolved aaronkine

    (@aaronkin)


    I am using this shortcode in a product template. is there a way to dynamically get the Product ID and insert that into the shortcode upon page load?

    so [twb_wc_reviews product_id=”THIS CAN BE DYNAMICALLY ENTERED” number=”5″]

    If you could give me the line of code where I would need to edit that would help too. thx

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Abu Bakar

    (@absikandar)

    Hello. You can do this by modifying core plugin file.

    1) Open file twb-output.php and comment out lines 16,17,18.

    2) On line 31, change $product_id with get_the_ID().

    Save the file.

    Now only use the shortcode: [twb_wc_reviews]

    It should work.

    Please note that in future if you update this plugin, modifications done to core file will be lost.

    If you get any error with above solution, let me know.

    Thanks for using my plugin.

    Abu

    Thread Starter aaronkine

    (@aaronkin)

    I wrote my own code that dynamically populates the product ID. I piggy backed on your shortcode and created another one.

    function get_product_id_for_twb_plugin() {
        global $product;
        $id = $product->get_id();
        return do_shortcode( '[twb_wc_reviews number="99" product_id="' . $id . '"]');
    }
    add_shortcode( 'review_slider', 'get_product_id_for_twb_plugin' );
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamic product ID’ is closed to new replies.