I m new in wordpress, I just set up an e-book store with the help of woocommerce, i want to add my custom shortcode in woocommerce plugin that fetch list of publishers and display as alphabatically. Publisher is the custom attribute of simple product. what i did
$shortcodes = array(
'product' => __CLASS__ . '::product',
'product_page' => __CLASS__ . '::product_page',
'product_category' => __CLASS__ . '::product_category',
'product_categories' => __CLASS__ . '::product_categories',
'add_to_cart' => __CLASS__ . '::product_add_to_cart',
'add_to_cart_url' => __CLASS__ . '::product_add_to_cart_url',
'products' => __CLASS__ . '::products',
'recent_products' => __CLASS__ . '::recent_products',
'sale_products' => __CLASS__ . '::sale_products',
'best_selling_products' => __CLASS__ . '::best_selling_products',
'top_rated_products' => __CLASS__ . '::top_rated_products',
'featured_products' => __CLASS__ . '::featured_products',
'product_attribute' => __CLASS__ . '::product_attribute',
'related_products' => __CLASS__ . '::related_products',
'shop_messages' => __CLASS__ . '::shop_messages',
'woocommerce_order_tracking' => __CLASS__ . '::order_tracking',
'woocommerce_cart' => __CLASS__ . '::cart',
'woocommerce_checkout' => __CLASS__ . '::checkout',
'woocommerce_my_account' => __CLASS__ . '::my_account',
'woocommerce_publishers' => __CLASS__ . '::publishers',
);
Publisher Function
public static function publishers(){
$args = array( 'posts_per_page' => 3,'posts_type' =>'product','post_status' =>'publish');
$lastposts = get_posts( $args );
foreach ( $lastposts as $post ) :setup_postdata( $post );
$prod_id = get_the_ID();
$terms = get_the_terms($prod_id, 'pa_publisher' );
print_r($terms);
endforeach;
wp_reset_postdata();
}
}
After that i m not getting the results, i want to know how to get all publisher names in alphabetic order. after execute the above code it returns error like this
WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy ) ) [error_data] => Array ( ) )
Help me plzz.. Thanks in Advance