Support » Plugin: Pods - Custom Content Types and Fields » Display taxonomies in pods form

  • Resolved kayapati

    (@kayapati)


    I am struggling to display the Taxonomies in pods form.

    I tried:

    Pod name: Talent
    Taxonomy: Talent Categories

    I created custom field “Talent Categories” with relationship to Talent Categories.

    When I fill the form I see all the Taxonomy associated and filled it, when Opened the post in wp admin the post is not saving into the Taxonomies “Talent Categories”.

    I would like to post to be saved in Taxonomy when I fill the POds form.

    I followed post_save meta with no luck.

    http://pods.io/docs/code/action-reference/pods_api_post_save_pod_item_podname/

    Any one can guide us?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jim True

    (@jimtrue)

    Taxonomy display (and selection) from the default WordPress Taxonomy metabox does not work on our built-in forms. You’d need to use Gravity Forms (with our Add-on) or Caldera Forms with their Custom Fields Add-on.

    If you’re just trying to set the Taxonomy automatically (and not allow the user a selection choice), you can either set the field to hidden or use this code (as referenced in the link above):

    
    <?php  
    add_action( 'pods_api_post_save_pod_item_films', 'my_tax_update', 10, 3 ); 
    
    function my_tax_update( $pieces, $is_new_item, $id ) { 
    
         //get the value of the 'genre' field 
         $term = (int) $pieces[ 'fields' ][ 'genre' ][ 'value' ]; 
    
         //if there is nothing there set $term to null to avoid errors 
         if ( empty( $term ) ) { $term = null; } 
    
         //Set the term for taxonomy 'genres' with $term 
         wp_set_object_terms( $id, $term, 'genres', false ); 
    }
    

    It does require, as that document indicates, a relationship field to the taxonomy in your Pod (and in the form) that is the value that is being written to the taxonomy. In the above example, ‘genre’ is a relationship field to the ‘genres’ taxonomy. When the user selects the genre from the list, it writes it to the ‘genres’ taxonomy. I also believe that example is using single select, not multiple select.

    Plugin Author Jim True

    (@jimtrue)

    Haven’t heard back from you since we replied, so I’m going to go ahead and mark this issue as resolved. If you’re still having an issue, please feel free to re-open this ticket or open a new one.

    kayapati

    (@kayapati)

    Thank you I got it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display taxonomies in pods form’ is closed to new replies.