Support

Account

Home Forums Backend Issues (wp-admin) Attachments Taxonomy does not Autosave

Solving

Attachments Taxonomy does not Autosave

  • Hi all,

    I am having an issue getting the taxonomy custom field to work on attachments. As it is currently, when I select tags for an attachment, it does not autosave them like it does if I were to edit the attachment name, description, etc.

    I have tried the solution posted here to no avail. My code:

    // Remove taxonomy from the attachment pages so the acf taxonomy can work
    function kw_remove_custom_taxonomy(){
      remove_meta_box('tagsdiv-post_tag', 'attachment', 'side' );
    }
    add_action( 'admin_menu', 'kw_remove_custom_taxonomy' );
    
    // Add this in to remove it from the popup editor
    function kw_attachment_remove_taxonomy( $fields ){
        unset($fields['post_tag']);
        return $fields;
    }
    add_filter( 'attachment_fields_to_edit', 'kw_attachment_remove_taxonomy' );

    If someone could help me get to the bottom of this issue, I’d greatly appreciate it.

  • ACF does not save any fields during autosave, there is a suggestion of how to do this here, but I don’t know if it works. https://github.com/elliotcondon/acf/issues/585

  • Thanks @hube2, but this did not yield a solution.

    I’ve actually found that it actually doesn’t even save the tags I set when I do it from the attachment page and click “update”. It would be really great to figure this out because the ACF fields for taxonomy are much better than the default WordPress textbox to type the taxonomy slug into.

  • Have you removed the standard meta boxes for the taxonomy? This might be helpful but I don’t know. https://support.advancedcustomfields.com/forums/topic/fields-not-working-on-image-attachments-details/

  • Thanks for all the quick replies. Still no luck, though.

    Removing the standard meta boxes is what the code in my first post was doing (provided it was correct code). I do have to say, though. The taxonomy meta boxes did not appear in the first place, until I used the following code in my functions file.

    function kw_add_tags_to_attachments() {
        register_taxonomy_for_object_type( 'post_tag', 'attachment' );
    }
    add_action( 'init' , 'kw_add_tags_to_attachments' );

    This is what adds the standard textbox that just takes the slug. But I removed this once I started working with the ACF taxonomy fields.

  • I know this has come up here before. Taxonomies do not work the same way on media as they work on other posts. I know there are some things that need to be customized, but my memory is foggy, it was a long time ago, and I can’t find anything.

    I think that you need to create your own acf/load_value and acf/update_value filters in order to apply the terms to the posts, but that’s just a guess.

  • I’ll have to take a look into what that entails, but I’ll post back if I figure it out. Thanks a bunch @hube2!

  • Hi Jared,
    I’m having the exact same troubles to autosave taxonomy on media/attachment popup. Did you figure it out?
    If someone could help I should really appreciate that…

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

The topic ‘Attachments Taxonomy does not Autosave’ is closed to new replies.