Home Forums General Issues Taxonomy Issues in Version 4.4.1+


Taxonomy Issues in Version 4.4.1+

  • Hi,

    I have a complex issue that’s appeared after updating to 4.4.2. I run a multisite network and have a taxonomy field on a post type on my main blog (blog id: 1). When the post is saved I hook into save_post and grab the term that was just added to post then use switch_to_blog (blog id: 2) to then set that term on a post (with the same post_type) on the child blog. If the term doesn’t exist on the child blog, I first create it by the slug.

    After using wp_set_object_terms() on the child blog and perform various other updates to the post, I then call do_action(“save_post”, $post_id, $post_obj); to inform other plugins an update has been made. After this the terms that I just set have now been removed from the post.

    This issue only started occurring after updating to 4.4.2 and if I downgrade to 4.4.0 the issue disappears.

    Any insight?

  • This may be the same problem as this:

    ACF 4.4.1 altered the Taxonomy field: Added compatibility for upcoming ‘term splitting’ in WP 4.2

    This may have something to do with it.

  • Hi @nathanfranklinau

    Thanks for the bug report.

    When you say:
    – After this the terms that I just set have now been removed from the post.

    Do you mean that the taxonomy field is not showing these values?
    Or do you mean that the terms are not being saved to the post at all?
    Can you check your DB to confirm this?


  • Hi mate,

    My ACF config for the taxonomy field is only on the post type in Blog 1. In Blog 2, there are no ACF fields at all. I’m using code to transfer the terms on the post in Blog 1 to the post in Blog 2 (same post type).

    The terms save fine to the post on Blog 1 and stay set as expected, however, after I manually call the save_post action while switched to blog 2, it removes the taxonomies on the post in blog 2 even though there are no ACF fields setup on that particular post type.

    Make sense?

  • Hi @nathanfranklinau

    Thanks for the info.

    Can you confirm that the terms are saved to ‘Blog 2’ before the ‘save_post’ action is called?

    Perhaps due to data available in $_POST['fields'] and cached field data that ACF is attempting to save…

    Can you do some debugging in the core/fields/taxonomy.php file.
    There is a function called set_terms and perhaps this is the function which is running on blog2 when it shouldn’t be.

    Can you place some debug code in that function and see if it runs on blog2? Perhaps the solution is to clear the value of $this->set_terms after the foreach loop on line 253


  • Hey

    Yeah the terms are saved prior to calling save_post. I’ll have a closer look into it hopefully in the day or 2.


  • Hi @nathanfranklinau

    Cool, try adding this to the bottom of set_terms function:

    this->set_terms = array();


Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.