0

I have a custom post type of products and I want to retrieve its taxonomy terms and display it in the backend. Am using ACF for these tabs and would want to filter the sizes attributes dynamically and name it in the tab.

enter image description here

    $postID              =   get_the_ID();
    $have_terms          =   get_the_terms($postID, 'product_attributes');

    if($have_terms){
    $parent_terms  = wp_get_post_terms( get_the_ID(),'product_attributes', array( 'parent' => 0, 'orderby' => 'id', 'order' => 'DESC', 'hide_empty' => false ) );   

This is the code in my template but I don't know how can I display it in the single product edit page.

4
  • advancedcustomfields.com/resources/acf-load_field look at the load fields hooks, you are gonna have to hit that custom field when it loads on the backend and change the tabs label based on the post id being currently loaded etc.
    – Ideatron
    Oct 28, 2018 at 3:17
  • @Ideatron hey, I make this work already but my problem now is that it's not saving. Like when I hit the update button and refreshed the page then all are gone. Oct 28, 2018 at 3:19
  • add_filter( 'acf/update_value/name=FIELD_NAME_YOUR_UPDATING', 'your_function', 10, 3 ); function Your_function($value, $post_id, $field ){ // do something to modify the value return $value; }
    – Ideatron
    Oct 28, 2018 at 3:48
  • where can I pull the $value data? You can check my code here stackoverflow.com/questions/53028195/… Oct 28, 2018 at 4:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.