2012-05-10 5 views
0

私はwoocommerceプラグインをwordpressのショップに使用しています - woocommerceは多数のタクソノミーを登録しています。コアファイルを変更せずにwordpressプラグインのタクソノミ登録設定を無効にする

show_in_nav_menus設定をtrueに変更したいのですが、コアファイルを変更するために悪いフォームが聞こえました。

はちょうど私のテーマののfunctions.phpでそれを上書きする方法はあります - コードの最後の引数私はあなたの関数であるとして、あなたがそれを置くことができる真の

register_post_type("product", 
     array(
      'labels' => array(
        'name'     => __('Products', 'woocommerce'), 
        'singular_name'   => __('Product', 'woocommerce'), 
        'add_new'    => __('Add Product', 'woocommerce'), 
        'add_new_item'   => __('Add New Product', 'woocommerce'), 
        'edit'     => __('Edit', 'woocommerce'), 
        'edit_item'    => __('Edit Product', 'woocommerce'), 
        'new_item'    => __('New Product', 'woocommerce'), 
        'view'     => __('View Product', 'woocommerce'), 
        'view_item'    => __('View Product', 'woocommerce'), 
        'search_items'   => __('Search Products', 'woocommerce'), 
        'not_found'    => __('No Products found', 'woocommerce'), 
        'not_found_in_trash' => __('No Products found in trash', 'woocommerce'), 
        'parent'    => __('Parent Product', 'woocommerce') 
       ), 
      'description'   => __('This is where you can add new products to your store.', 'woocommerce'), 
      'public'    => true, 
      'show_ui'    => true, 
      'capability_type'  => 'post', 
      'capabilities' => array(
       'publish_posts'   => 'manage_woocommerce_products', 
       'edit_posts'   => 'manage_woocommerce_products', 
       'edit_others_posts'  => 'manage_woocommerce_products', 
       'delete_posts'   => 'manage_woocommerce_products', 
       'delete_others_posts' => 'manage_woocommerce_products', 
       'read_private_posts' => 'manage_woocommerce_products', 
       'edit_post'    => 'manage_woocommerce_products', 
       'delete_post'   => 'manage_woocommerce_products', 
       'read_post'    => 'manage_woocommerce_products' 
      ), 
      'publicly_queryable' => true, 
      'exclude_from_search' => false, 
      'hierarchical'   => false, // Hierarcal causes memory issues - WP loads all records! 
      'rewrite'    => array('slug' => $product_base, 'with_front' => false, 'feeds' => $base_slug), 
      'query_var'    => true,    
      'supports'    => array('title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields'), 
      'has_archive'   => $base_slug, 
      'show_in_nav_menus'  => true 
     ) 
    ); 

答えて

0

に変更する必要があります下に。 phpファイルでは、プラグインのファイルを上書きします。

add_action('init', 'register_my_post_type'); 
function register_my_post_type() { 
    /* here */ 
} 

と、これはあなたのプラグインのinitアクションの後に実行されます確認してください。 は、initのアクションからそれを呼び出すように注意してください。おそらくより低い優先度を追加する必要があるかもしれません:

add_action('init', 'register_my_post_type', 1000); 
// 1000 -> lower priority, will run after the plugin init action 
+0

lovely jubbly - 明確にするために、私は本質的に上書きしています - それはどの機能にも当てはまりますか?この種のことを自分自身でやってみると、私は以前に宣言された関数エラーが出ることがあります。 – JorgeLuisBorges

関連する問題