Support

Account

Home Forums ACF PRO Weird problem with custom plugin and ACF taxonomy field with load/save terms

Helping

Weird problem with custom plugin and ACF taxonomy field with load/save terms

  • I have a very simple custom plugin. In my plugin’s init function I have the line $asdfasdfasdf = get_field( 'sub_industry', $post_id ); The init function is called on every page load. (it’s just here for testing purposes). The sub_industry field is a Taxonomy field and it has Load Terms and Save Terms checked. The $asdfasdfasdf variable contains the correct data.

    The problem is when I’m editing a post that uses the sub_industry field, it won’t load the checked/unchecked terms for that post. If I remove the line $asdfasdfasdf = get_field( 'sub_industry', $post_id ); from my plugin then the terms show up fine on the post. Also if I set the sub_industry field to NOT save/load terms, then it displays the checked/unchecked terms.

    It’s a very weird problem and I have no idea why just calling the get_field function would have any affect on which terms are loaded for a post.

  • Nevermind, I figured it out. The problem was that the plugin’s init function was being run earlier than the init function that registered the taxonomies. Giving my plugin’s init action a later priority got everything working correctly.

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

You must be logged in to reply to this topic.