• We just upgraded an old WP site from 5.x to 6.1.1 and everything works except Radio Buttons for Taxonomies is adding in duplicates for each custom taxonomy that is selected.

    The duplicates have the ID of the selected taxonomy as its title, so we see a new entry called ’94’, which is the ID of the selected item in the radio button list.

    I noticed a note on 1.4.5 “Automatically unset default taxonomy column (if conventionally named) to prevent duplicate columns” and wonder if that’s related to this?

    We’re running Version 2.4.6 so this should be an issue though.

    It’s a Bedrock/Sage site, if that matters, and everything else is at latest version.

    Any ideas how I can troubleshoot this?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    Are you able to reproduce this with an isolated setup? Ie, this plugin is the only active plugin and using a core theme (like Twenty Twenty Three). You can use Health Check to test this without impacting your live site.

    What kind of taxonomy is this? Hierarchical (like categories) or Non-Hierarchical (like tags)?

    Can you walk me through the steps required to reproduce the issue?

    Thread Starter ralpharama

    (@ralpharama)

    Thanks for the reply. Curiously this was fixed by adding in this line to the definition of the taxonomy:

    'meta_box_cb'       => 'post_categories_meta_box',

    With this present the duplication doesn’t occur, without it the radio buttons still appear but the duplicates come back on any post update!

    I posted this on StackExchange where I mostly talked to myself but it has more details!

    https://wordpress.stackexchange.com/questions/414317/taxonomy-entries-are-spawning-copies-of-existing-entries-with-the-new-title-as-t

    • This reply was modified 1 year, 8 months ago by ralpharama.
    Plugin Author HelgaTheViking

    (@helgatheviking)

    “Automatically unset default taxonomy column (if conventionally named) to prevent duplicate columns” refers to the wp-admin/edit.php table and shouldn’t have an impact on the single product page.

    lol at talking to yourself… hey we all need to rubber duck some things. Ok, so if you look at the args for register_taxonomy() : https://developer.www.ads-software.com/reference/functions/register_taxonomy/

    meta_box_cb bool|callable

    Provide a callback function for the meta box display. If not set, post_categories_meta_box() is used for hierarchical taxonomies, and post_tags_meta_box() is used for non-hierarchical. If false, no meta box is shown.

    So when you do not register a metabox and you have a non-hierarchical taxonomy (like your SO code suggests), then WordPress will automatically use their tag metabox. You didn’t say, but did you happen to have 2 metaboxes?

    My plugin is always displaying the terms in a list with IDs as the value, so if some other save routine is listening it will possibly save terms as IDs…. which is still interesting since currently the input are named differently (something I am exploring changing in the future, but am afraid of walking the plugin into this situation).

    I try my best to unset metaboxes, I would have to try to test your use case to see what happened and if it’s preventable.

    Plugin Author HelgaTheViking

    (@helgatheviking)

    ps – just tried this:

    function kia_test_taxonomy_with_rb4t() {
       $args = array(
    	'hierarchical'      => false,
    	'label' => __( 'Article Type', 'sage' ),
    	'public'            => true,
    	'show_admin_column' => true,
    	'rewrite'           => array( 'slug' => __( 'article-type', 'sage' ) ),
    	  );
    	
         register_taxonomy( 'article_type', 'post', $args );
    }
    add_action( 'init', 'kia_test_taxonomy_with_rb4t' );

    So missing the meta_box_cb param you mentioned changing… and I can’t reproduce. Would still be curious if you can walk me through sets to repro.

    Thread Starter ralpharama

    (@ralpharama)

    So I’m not sure what I can provide to help replicate this except for paste the two definitions. I can confirm that for me, removing the meta_box_cb results in the duplicates appearing. Adding it back in makes it work properly. It’s odd as the DOM of the edit page in both scenarios is identical, so I suspect you are right – something else is listening to the save maybe and causing issues. Here’s the definition of both. I tried removing one by the way and it happens with just one box enabled, so I’m not sure having multiple is the issue.

      /* Article Type */
      $labels = array(
        'name'              => _x( 'Article Type', 'taxonomy general name', 'sage' ),
        'singular_name'     => _x( 'Article Type', 'taxonomy singular name', 'sage' ),
        'search_items'      => __( 'Search Article Types', 'sage' ),
        'all_items'         => __( 'All Article Types', 'sage' ),
        'parent_item'       => __( 'Parent Article Type', 'sage' ),
        'parent_item_colon' => __( 'Parent Article Type:', 'sage' ),
        'edit_item'         => __( 'Edit Article Type', 'sage' ),
        'update_item'       => __( 'Update Article Type', 'sage' ),
        'add_new_item'      => __( 'Add New Article Type', 'sage' ),
        'new_item_name'     => __( 'New Article Type Name', 'sage' ),
        'menu_name'         => __( 'Article Types', 'sage' ),
      );
    
      $args = array(
        'hierarchical'      => false,
        'labels'            => $labels,
        'public'            => true,
        'show_admin_column' => true,
        'meta_box_cb'       => 'post_categories_meta_box',
        'rewrite'           => array( 'slug' => __( 'article-type', 'sage' ) ),
      );
    
      register_taxonomy( 'article_type', array( 'post' ), $args );
    
      /* Access Type */
      $labels = array(
        'name'              => _x( 'Access Type', 'taxonomy general name', 'sage' ),
        'singular_name'     => _x( 'Access Type', 'taxonomy singular name', 'sage' ),
        'search_items'      => __( 'Search Access Types', 'sage' ),
        'all_items'         => __( 'All Access Types', 'sage' ),
        'parent_item'       => __( 'Parent Access Type', 'sage' ),
        'parent_item_colon' => __( 'Parent Access Type:', 'sage' ),
        'edit_item'         => __( 'Edit Access Type', 'sage' ),
        'update_item'       => __( 'Update Access Type', 'sage' ),
        'add_new_item'      => __( 'Add New Access Type', 'sage' ),
        'new_item_name'     => __( 'New Access Type Name', 'sage' ),
        'menu_name'         => __( 'Access Types', 'sage' ),
      );
    
      $args = array(
        'hierarchical'       => false,
        'labels'             => $labels,
        'public'             => true,
        'publicly_queryable' => false,
        'show_ui'            => true,
        'show_admin_column'  => true,
        'meta_box_cb'        => 'post_categories_meta_box',
        'rewrite'            => array( 'slug' => __( 'access-type', 'sage' ) ),
      );
    
      register_taxonomy( 'access_type', array( 'post', 'page' ), $args );

    If you’d like anything else do let me know! Or if you have any idea how I could find the hidden listener/function maybe?

    Thanks!

    • This reply was modified 1 year, 8 months ago by ralpharama.
    Plugin Author HelgaTheViking

    (@helgatheviking)

    thanks for this! I’m away from my keyboard most of this week so not sure how much up get to look at this, but I’ll try when i get a chance.

    you can try Health Check plugin to test turning off all plugins/custom themes without impacting your live site

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Duplicates appearing on save’ is closed to new replies.