Add this code to your functions.php file and then you can use [product_title id="123"] shortcode
If you want other product meta you can edit the function to return any product data you would want
/**
* Product title shortcode.
* `[product_title id="123"]` to get a specific product title, by ID
*
* @return string The post's title.
*/
add_shortcode( 'product_title', function( $atts ) {
$atts = shortcode_atts( array(
'id' => get_the_ID(),
), $atts, 'post_title' );
return get_the_title( absint( $atts['id'] ) );
});
Related Posts:
- Where to put my code: plugin or functions.php?
- Attach a Custom Post Type to a Woocommerc product as a variation or add-on [closed]
- WordPress Custom Shortcode Conflicting with Media Library
- How to solve suspected memory issue in custom WordPress loop?
- Using shortcodes to parse POST request (containing the data from a front-end form)
- IF statement in a do_shortcode
- Set meta_query only for specific post type
- Strip shortcode from specific post types (formats)
- Pagination in a Shortcode. Get_next_posts_link not working but get_previous_posts_link works fine right next to it
- Woocommerce query specific product from specific category
- Export Custom Post Type posts with all Custom Fields and Custom Texonomy associated with it
- Is it possible to create a shortcode that will query a post based on taxonomies?
- Get custom posts with certain ids in a custom loop using a shortcode
- Custom Post Type Loop within Shortcode
- Create custom post type on successful woocommerce order [closed]
- Shortcode doesn’t display in custom post type
- Add category attribute to custom shortcode
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- how to get URL of media uploaded to WordPress via media_handle_sideload()
- How to create shortcode to display custom field value on a custom post type
- How to enable shortcodes in a custom post type?
- How to display product subcategories into my custom post type single page
- Get custom fields from a custom post type with a shortcode
- WordPress export tool doesn’t export post-format value of custom post type?
- Get custom post type list for every category shortcode
- Create a clone from one WordPress site to another in a few minutes
- Woocommerce search pagination not working
- WooCommerce Customer Role Delete Custom Post Type
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- Exporting individual custom post type post for deployment?
- Woocommerce custom field search in custom post type [closed]
- Modifying custom post type created by WooCommerce
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Shortcode for CPT post content in a page
- How to retrieve category of a post in have_post loop?
- Sort posts in loop by the WooCommerce Membership of the author
- the_post() is printing titles in page footer
- Add custom attributes to a post
- post_type internal ID?
- Copy order items with metadata between orders – Woocommerce
- Filter content in shortcode
- Update Post Status On Woocommerce Payment Complete
- Shortcode with WP_Query more than once on one page
- Custom Post Type to replace Woocommerce products – page not found error
- CPT as Product in WooCommerce
- Change permalink for custom_post_type using custom_post_meta (woocommerce)
- How to call a post’s metadata in shortcode.php?
- Trying to write shortcode with get_post_meta but isn’t working
- Shortcode / WP_Query in post changes context
- Modify a plugin function output from another plugin
- Problems making shortcode with custom post types and taxonomy
- Using Custom Post Meta Values in Shortcode
- Content in WP Editor displayed below CPT shortcode [duplicate]
- How to make post templates to include shortcodes only?
- Two-way synchronizing of a post type among multisite blogs
- Is it a connection or relationship between 2 custom post types?
- How to show Custom Post Type – Case Study using Shortcode & ACF
- Custom Post type to Woocommerce Product type
- Alike Shortcode using in Custom Shortcode
- Display CPT Category List as Shortcode
- Can Someone help me to create Short Code for displaying a category posts
- Shortcode with loop stacks output
- background featured image display using shortcode
- Add two custom product type
- How to display the post using a shortcode in WordPress?
- How to return/export only data showing on screen in custom post type view all screen
- How to generate auto shortcode for custom post type same as Elementor Template?
- Shortcode and get_template_part
- Exporting CPT from dev site and import into live site?
- WooCommerce – Custom related product (Spareparts)
- Convert attribute woocommerce terms (taxonomy terms) in posts of custom post type
- How to seperate posts by categories?
- Do not parse shortcode in CPT
- Custom Taxonomy not working front side Woocommerce
- WooCommerce breadcrumb display custom posts instead of product data
- Extracting Post ID and passing through as an attribute in a shortcode
- Enable shortcodes on custom post type
- Custom meta box in editor of custom post type not working
- Get Non-Paginated Index of Post in Paginated Query
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- Plugin Error on activating
- Modify shortcode to work with custom taxonomies and slugs
- shortcode order for event custom post type
- Shortcodes in custom post fields without the_content()
- Shortcode display CPT Query only showing 1 post?
- Custom Post Type vs Shortcode: Which one is more performant?
- Using get_terms() as shortcode attribute
- shortcode for recent custom type post
- Navigation links to posts in current term shortcode
- WP_Query wooCommerce category
- How to Create Short Code Using Custom Post type
- Display posts from another page on home page in wp-editor
- Issue On Listing Woocommerce Parent Tag List
- How to loop through a custom post type using a shortcode and output each element in the loop using shortcodes
- Passing postid of Testimonial Custom Post in Shortcode Parameter
- cannot export data from CPT UI (books)
- strange issue with get_post_type() when using it in a shortcode in text widget
- select categories by ids/display terms only selected
- Pre defined checkbox / radio button state based on value stored in ACF fields in checkout form WooCommerce
- Display the progress of post achievement with percentage against target in wordpress dashboard