Search This Blog

Friday 1 March 2019

Add woocommerce custom product tabs.

Add in your functions.php

add_filter( 'woocommerce_product_tabs', 'woocommerce_custom_product_tabs' );

function woocommerce_custom_product_tabs( $tabs ) {

 $tabs['courses_tab'] = array(
        'title'     => __( 'Courses', 'woocommerce' ), //Tab title
        'priority'  => 100, // Tab priority
        'callback'  => 'courses_tab_content' //callback function
    );
return $tabs;

  }

//callback function
function courses_tab_content() {
    echo '<h2>Courses</h2>';
    echo '<p>Courses tab.</p>';
}


Sunday 24 February 2019

Get Post By Meta value in wordpress.

function getPostByMetavalue(){
// the meta_key 'diplay_on_homepage' with the meta_value 'true'
$args = array(
    'post_type'        => 'product', //your custom post type name
    'meta_key'         => '_regular_price', //Meta key what do you want to search by key.
    'meta_value'       => 50, // Meta Values
'posts_per_page'   => -1 // Post per page -1 means show all post you can add your choice like 10 or 5...
);
$query = new WP_Query( $args );
echo "<pre>";print_r($query);echo "</pre>";
}
add_shortcode('getPostByMetavalue_short','getPostByMetavalue');