Viewing 4 reply threads
  • Author
    Posts
    • #4224
      vagelis
      Member

      I’ve created a taxonomy select field in my metabox. For the other metaboxes i use get_post_meta, but I cannot figure out what to use here. Tried get_terms but with no luck. Below is my piklist field.

      piklist('field', array(
        'type' => 'select'
        ,'scope' => 'taxonomy'
        ,'field' => 'manufacturers'
        ,'label' => 'Κατασκευαστής σκάφους'
        ,'choices' => array(
            '' => 'Επιλέξτε κατασκευαστή'
          )
          + piklist(get_terms('manufacturers', array(
            'hide_empty' => false
          ))
          ,array(
            'term_id'
            ,'name'
          )
        )
      ));
    • #4225
      Steve
      Keymaster

      @vagelis– Easily getting term meta is something that is lacking from WordPress. You have two choices:
      1) Use WordPress function get_metadata.
      2) There’s a helper function in Piklist you can use. get_term_meta works exactly like get_post_meta.

    • #4226
      vagelis
      Member

      I’ve managed to get it working with this:

      $terms = wp_get_post_terms($post->ID, 'manufacturers', array("fields" => "names"));
      echo $terms[0];

      But it’s not the piklist way. I could not figure out what to put on the “key” value on get_term_meta to get the name of the ‘manufacturer’. Care to elaborate Steve? Thanx for the help.

    • #4227
      Steve
      Keymaster

      I misunderstood what you wanted. This is the perfect way to do it. Piklist way == WordPress way.

    • #4228
      vagelis
      Member

      Ok, no harm done. 🙂 All solved here. Thanx again.

Viewing 4 reply threads
  • The topic ‘Get value from taxonomy select field’ is closed to new replies.