0

We recently upgraded a very old WordPress 5.x site to WordPress 6.1.1 and all seemed to go well but then it was reported that some taxonomies were generating new entries randomly.

So we have a taxonomy called article_type, which has entries like

  • News - taxonomy=article_type & tag_ID=84 & post_type=post
  • Opinion - taxonomy=article_type & tag_ID=90 & post_type=post

Suddenly all these new entries are starting to appear at the top of the list in edit-tags.php page, like this

the new entries

  • 431 - taxonomy=article_type & tag_ID=47033 & post_type=post
  • 90 - taxonomy=article_type & tag_ID=47036 & post_type=post

So, the title in each new case is the ID of an existing entry.

The taxonomy is declared like this in code:

  /* 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,
    'rewrite'           => array( 'slug' => __( 'article-type', 'sage' ) ),
  );

  register_taxonomy( 'article_type', array( 'post' ), $args );

I wonder if anyone has any ideas where to begin troubleshooting this?

Many thanks!

edit: more info

So it seems when you edit/add a post and use a new article_type, like this: if we add this, it appears as a new entry with title=id

Then this appears as a new numeric entry at the top of the article_type list. So it seems there's some code that's incorrectly grabbing/updating these and adding this in on a post update!

I have no idea where to even begin to look for this!

edit: more info

I wonder if this has anything to do with it? The only two taxonomies affected:

these are the affected taxonomies

4
  • 1
    There's nothing in your code that would do this, but the interface for selecting an Article Type in your screenshot does not appear to be the standard interface for choosing taxonomy terms. So it seems like you're using a plugin, or have other code, that is changing the way taxonomy term selection works. I'd wager that code is responsible, whatever it is. Mar 2 at 8:56
  • @jacob-peattie There's a plugin running called 'Radio Buttons for Taxonomies' that only has these two taxonomies selected! Suspicious eh?
    – Ralpharama
    Mar 2 at 9:04
  • So it's this wordpress.org/plugins/radio-buttons-for-taxonomies/#developers which has a note on 1.4.5 "Automatically unset default taxonomy column (if conventionally named) to prevent duplicate columns" however, our version is the latest :(
    – Ralpharama
    Mar 2 at 9:10
  • So it looks like it IS this. If I remove these from that plugin then updates don't spawn new items. So now I just need to figure out a way to present radio options without this plugin I suppose!
    – Ralpharama
    Mar 2 at 9:16

1 Answer 1

0

I'll answer this myself, though kudos to @jacob-peattie for noticing the selection box was non-standard and a likely culprit.

So we had the 'Radio Buttons for Taxonomies' plugin running (up to date) with the affected taxonomy types selected there.

When we removed the taxonomies from there, the problem stopped.

But we wanted radio buttons here so tried a few things. One thing that did work was this in the end:

This was our original arguments for the taxonomy, and this produced duplicates:

  $args = array(
    'hierarchical'      => false,
    'labels'            => $labels,
    'public'            => true,
    'show_admin_column' => true,
    'rewrite'           => array( 'slug' => __( 'article-type', 'sage' ) ),
  );

When we add this meta_box_cb line it works as expected and no more duplicates:

  $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' ) ),
  );

It seems a bit crazy, but I tested this several times and at least in our case it is the solution.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.