WordPress shortcodes allow you to save time. For example, on my WooCommerce product pages I found myself typing the product title at least three times: in the product name input field, ok, but also again in the product long description and in a custom product tab inside a text link.
So, while finding ways to save time and reduce errors and typos, I coded the shortcode below so that I could avoid writing the title 3 times (and they’re very long!).
How does it work? Simply use [post_title] in a WooCommerce product, WordPress page, WordPress post or custom post and this will magically turn into the current post title. Simple!
PHP Snippet: Print Current WooCommerce Product / WordPress Post Title Via a Shortcode
Yep, it’s only one line of PHP magic!
/**
* @snippet Echo Current Product/Post Name (Shortcode)
* @usage Use [post_title] on the current post
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 8
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
add_shortcode( 'post_title','get_the_title' );