Last active
August 29, 2015 13:55
-
-
Save technoknol/8782694 to your computer and use it in GitHub Desktop.
Woocommerce Create/Add your own tab on Single Product Page
This file contains 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
<?php | |
/* | |
* Created By (Nick Name): TechnoKnol | |
* blog : http://technoknol.blogspot.com | |
* Purpose : Add your own code to Woocommerce Single Product Page | |
* | |
* */ | |
/* | |
* Add this code to your theme's 'functions.php' file | |
* first of all add custom field in Add new product page | |
* then get it's slug from any of this below function | |
* the_meta() or | |
* get_post_meta(get_the_ID()) ; | |
* | |
* */ | |
add_filter( 'woocommerce_product_tabs', 'panorama_view' ); | |
function panorama_view($tabs = array()) { | |
global $product , $post ; | |
// 360 Panorama view tab - shows 360 view of product | |
if ( get_post_meta($post->ID,'360 view') ) // this is meta slug (read above comments) | |
$tabs['360view'] = array( | |
'title' => __( '360 View', 'woocommerce' ), // this first parameter will show on page | |
'priority' => 50, // priority to arrange tab in sequence | |
'callback' => 'wp_360_view' // this is name of function to call in newly created Tab | |
); | |
return $tabs ; | |
} | |
function wp_360_view() { | |
global $post ; | |
// here your code goes. | |
// put the code of what you want to print in new tab. | |
// it's my code for just demo. | |
$text360 = get_post_meta($post->ID,'360 view'); | |
echo "<i>".$text360[0]."</i>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment