Viewing 3 reply threads
  • Author
    Posts
    • #1179
      ken
      Blocked

      add_filter(‘piklist_taxonomies’, ‘custom_tax’);
      function custom_tax($taxonomies)
      {
      $taxonomies[] = array(
      ‘post_type’ => ‘product’ //custom post type
      ,’name’ => ‘custom_tax’
      ,’show_admin_column’ => true
      ,’hide_meta_box’ => true
      ,’configuration’ => array(
      ‘hierarchical’ => true
      ,’labels’ => piklist(‘custom_tax’, ‘custom Category’)
      ,’show_ui’ => true
      ,’query_var’ => true
      ,’rewrite’ => array(
      ‘slug’ => ‘custom_tax’
      )
      )
      );
      return $taxonomies;
      }
      var_dump(get_terms(‘custom_tax’));

      display:

      object(WP_Error)[233]
      public ‘errors’ =>
      array (size=1)
      ‘invalid_taxonomy’ =>
      array (size=1)
      0 => string ‘Invalid taxonomy’ (length=16)
      public ‘error_data’ =>
      array (size=0)
      empty

    • #1183
      Steve
      Keymaster

      @kenget_terms() will only show the default WordPress taxonomies unless you hook it to init or after:

      function show_custom_tax()
      {
       $terms = get_terms('custom_tax', array(
       	'hide_empty' => false
       ));
      
       print_r($terms);
      }
      add_action('init','show_custom_tax');

      This is not a Piklist “thing”, it’s a WordPress “thing”. Try registering your custom tax using register_taxonomy() and you’ll get the same results.

    • #1184
      Steve
      Keymaster

      You were also using the wrong function for labels. It should be:

      ,'labels' => piklist('taxonomy_labels', 'custom Category')

    • #1187
      ken
      Blocked

      @Steve Thank you very much!!!

Viewing 3 reply threads
  • The topic ‘get_terms('custom_tax') is error’ is closed to new replies.