• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Home
  • Blog
  • Sample Page

WordPress Tips

Just another WordPress site

Add WooCommerce Product Price as a Shortcode

September 28, 2019 Leave a Comment

Add WooCommerce Price as a shortcode using the product ID for the correct product

add_shortcode( ‘cl_product_price’, ‘cl_woo_product_price_shortcode’ ); /** * Shortcode WooCommerce Product Price. * */ function cl_woo_product_price_shortcode( $atts ) { $atts = shortcode_atts( array( ‘id’ => null ), $atts, ‘cl_product_price’ ); if ( empty( $atts[ ‘id’ ] ) ) { return ”; } $product = wc_get_product( $atts[‘id’] ); if

Filed Under: Shortcode, woocommerce, WordPress Tagged With: Shortcode, woocommerce, WordPress

Reader Interactions

Related Posts

  • WooCommerce Direct Checkout Review: Add a “Buy Now” Button + More
  • Media Temple Managed WordPress Hosting: Overview and Review
  • Transform Your Gym with a Booking Plugin
  • Hotjar Heatmap Analytics: An Overview and Review

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Copyright ©2019 · WPress.Tips - All Rights Are Reserved · Powered by Genesis Framework