Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey @discountpleasure,
    Add the following code to your theme’s functions.php or a custom plugin:

    function display_product_shortlink() {
    if (is_product()) {
    global $post;
    echo '<p><strong>Shortlink: </strong><a href="' . wp_get_shortlink($post->ID) . '">' . wp_get_shortlink($post->ID) . '</a></p>';
    }
    }
    add_action('woocommerce_single_product_summary', 'display_product_shortlink', 25);

    If you’re using Elementor or another builder, register a shortcode:

    function product_shortlink_shortcode() {
    global $post;
    if (!is_product()) return '';
    return '<p><strong>Shortlink: </strong><a href="' . wp_get_shortlink($post->ID) . '">' . wp_get_shortlink($post->ID) . '</a></p>';
    }
    add_shortcode('product_shortlink', 'product_shortlink_shortcode');

    If you need anything, feel free to connect with me.

    Best Regards
    Ravindra Singh Meyda

    Plugin Support Mahfuzur Rahman(woo-hc)

    (@mahfuzurwp)

    Hi @discountpleasure,

    Thanks for reaching out! To display the product shortlink on the product page, you would need to use custom code, which is outside of our support scope.

    We recommend consulting with a developer who can help you implement this feature. Alternatively, you can join our community Slack channel, where fellow developers might be able to offer guidance and suggestions: https://woocommerce.com/community-slack/.

    Thank you.

    Thread Starter discountpleasure

    (@discountpleasure)

    @ravindra107 Thank you so much !

    @mahfuzurwp Someone replied, but it doesn’t display very nicely, is there a way to do better please ? Thanks a lot !

    Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello discountpleasure,

    Thank you for your reply.

    I am glad to know that Ravindra Singh Meyda shared a solution with you.
    Please note that custom code is not covered by our support policy, there you may ask Ravindra for any customizations to the code.

    It would be helpful if you could share a screenshot.
    Maybe it can be fixed by adding some CSS code.

    Have a great day!

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