Viewing 2 reply threads
  • Author
    Posts
    • #3527
      byronyasgur
      Member

      I am trying to make a select box for Woocommerce categories on another custom post type. I am using the code below but it doesn’t appear to be saving in the database … actually I cant find categoryreq in the database which I assumed I would find in the wp_terms table. Can you tell me how to do this?

      I was using this page for reference — https://piklist.com/user-guide/tutorials/display-taxonomies-as-a-dropdown-or-radio-buttons/

      
      piklist('field', array(
          'type' => 'select'
          ,'scope' => 'taxonomy'
          ,'field' => 'categoryreq'
          ,'label' => 'Categories'
          ,'description' => 'Terms will appear when they are added to this taxonomy.'
          ,'choices' => piklist(
            get_terms('product_cat', array(
              'hide_empty' => false
            ))
            ,array(
              'term_id'
              ,'name'
            )
          )
        ));
    • #3529
      byronyasgur
      Member

      Actually I think I figured this out … looks like I don’t need to set the scope for what I’m doing and setting it to taxonomy was wrong for what I was trying to do … I just left it out so it defaults to postmeta and it all works fine

      piklist('field', array(
          'type' => 'select'
          ,'field' => 'categoryreq'
          ,'label' => 'Categories'
          ,'description' => 'Terms will appear when they are added to this taxonomy.'
          ,'choices' => piklist(
            get_terms('product_cat', array(
              'hide_empty' => false
            ))
            ,array(
              'term_id'
              ,'name'
            )
          )
        ));
      
    • #3530
      Steve
      Keymaster

      @byronyasgur– Glad you figured it out. Let us know if you need any more help. Closing ticket.

Viewing 2 reply threads
  • The topic ‘Display Woocommerce Categories in Select list on separate CPT’ is closed to new replies.