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
- Generate Shortcodes by Taxonomy
- Is it possible to create a shortcode that will query a post based on taxonomies?
- WP_Query is printing out only one post when posts_per_page is set to multiple
- 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
- Shortcode for display posts in wp-editor
- 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
- Can a shortcode included in post content add styles to the ?
- How to retrieve category of a post in have_post loop?
- Sort posts in loop by the WooCommerce Membership of the author
- Checking if looped item has a parent inside a shortcode
- get_post_meta is not working inside shortcode
- How to set up Custom Post Type archive page as Front page
- How can I add a shortcode to query Custom Post Type with ACF in WordPress?
- Get Posts by Category, Tag , and CPT Taxonomy
- post_type internal ID?
- Shortcode is displaying the content on top of the page [duplicate]
- Filter content in shortcode
- Shortcode with WP_Query more than once on one page
- posts within custom post type all share the same content in the front-end
- Custom Post Type to replace Woocommerce products – page not found error
- Shortcode / WP_Query in post changes context
- Custom Post Type or Shortcode, What to choose? [closed]
- 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?
- Is it a connection or relationship between 2 custom post types?
- Migrate Custom Post Type with Custom Fields data and parent child order
- 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
- Shortcode with loop stacks output
- Add two custom product type
- Duplicate the “Orders” list on Admin Page
- How to display the post using a shortcode in WordPress?
- Sudden 404 pages on product category archives
- 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?
- Custom Post type shortcodes
- Shortcode and get_template_part
- WooCommerce – Custom related product (Spareparts)
- Convert attribute woocommerce terms (taxonomy terms) in posts of custom post type
- How to seperate posts by categories?
- WooCommerce change
- Display a list of sub-pages of Custom Post Type Parent Page
- Do not parse shortcode in CPT
- Search in multiple specific post types
- Shortcode in excerpt
- Custom Taxonomy not working front side Woocommerce
- WooCommerce breadcrumb display custom posts instead of product data
- Enable shortcodes on custom post type
- Custom meta box in editor of custom post type not working
- Custom Taxonomy is disabled on Edit page
- 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
- shortcode order for event custom post type
- Shortcode display CPT Query only showing 1 post?
- Custom Post Type vs Shortcode: Which one is more performant?
- How to call Shortcode categories for custom post types?
- Using get_terms() as shortcode attribute
- Creating shortcodes with user created forms
- How to Create Short Code Using Custom Post type
- custom post types shortode stays on top of other page contents. Is there a bug?
- Issue On Listing Woocommerce Parent Tag List
- Passing postid of Testimonial Custom Post in Shortcode Parameter
- Problem with shortcode