Created
August 11, 2018 02:01
-
-
Save iWebbers/532ce5bb8933aa58a1becc519a6d0bdb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Get WooCommerce product url by ID via shortcode: [iw_product_url id=''] | |
| function iw_product_url_shortcode( $atts ) { | |
| $atts = shortcode_atts( array( | |
| 'id' => null, | |
| ), $atts, 'bartag' ); | |
| $html = ''; | |
| if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ | |
| $_product = wc_get_product( $atts['id'] ); | |
| $html = $_product->get_permalink(); | |
| } | |
| return $html; | |
| } | |
| add_shortcode( 'iw_product_url', 'iw_product_url_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment