doucai6663 2015-06-29 17:09
浏览 44

如何在woocommerce中获取特定属性的所有值,它在WP_ERROR_OBJECT中显示invalid_taxonomy

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类
    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏