• I have a custom taxonomy created called “Locations”.
    Now, i try to create a navigation menu in Appearance | menus called “Locations”.
    On The left-hand side there is “Add menu items”, the “Locations” is displayed
    and pull-down, select it and choose “select all” checkbox.
    The whole hierarchy custom taxonomy is now displayed on “Menu Structure” panel on
    the right-hand side. Click “Save Menu”, get fatal error (on both WP 5.9.3 and 6.0.1):

    Fatal error: Uncaught Error: Object of class WP_Error could not be converted to string in /nas/content/live/tcshop/wp-includes/formatting.php:1015 Stack trace: #0 /nas/content/live/tcshop/wp-includes/nav-menu.php(499): wp_specialchars_decode(Object(WP_Error)) #1 /nas/content/live/tcshop/wp-admin/includes/nav-menu.php(1202): wp_update_nav_menu_item(581, 23294, Array) #2 /nas/content/live/tcshop/wp-admin/nav-menus.php(424): wp_nav_menu_update_menu_items(581, ‘Locations’) #3 {main} thrown in /nas/content/live/tcshop/wp-includes/formatting.php on line 1015`

    • This topic was modified 2 years, 3 months ago by hiheaven01.
Viewing 4 replies - 1 through 4 (of 4 total)
  • @hiheaven01 Thank you for providing the detailed steps and error messages that you were getting. I followed your steps in my own environment (using the Twenty Twenty theme), registered a custom taxonomy called ‘locations’ and followed the steps you listed. Still, unfortunately, I’m not able to reproduce the issue.

    I think this might be a bug in a plugin or theme. Please attempt to disable all plugins and use one of the default (Twenty*) themes. If the problem goes away, enable them one by one to identify the source of your troubles.

    If the issue is still happening after disabling plugins and switching to default themes, something specific with your site or content setup could trigger a WordPress core bug. If that’s the case, would you be able to add additional details to this support ticket, such as pasting the code used to register the taxonomy? I’d also be curious how many taxonomy terms are being added and whether that plays a role here.

    I hope you can get to the bottom of the issue after following the troubleshooting steps mentioned.

    Thread Starter hiheaven01

    (@hiheaven01)

    It’s duplicated in brand new site!
    I have Local software installed on my PC from localwp.com.
    Created a brand-new site (WP 6.0.1, PHP 7.4.1, theme twentytwentytwo).
    I have my own plugin just to create a “product custom taxonomy”, nothing else.
    No other plugin besides woocommerce and the code to create custom tax above.
    Goto Appearance | Menus and create menu for this custom tax.
    Once click at “Save menu”. get fatal error:

    https://ibb.co/1dqh4ML

    The code:

    https://ibb.co/rmNsc78

    Thread Starter hiheaven01

    (@hiheaven01)

    Ah, when i use the code above (see image attached above).
    the error is triggered.

    But when created with Custom Post Taxonomy plugin (https://www.ads-software.com/plugins/custom-post-type-ui/), the error is NOT there.

    @hiheaven01 I’m glad you were able to create a workaround. It looks like it’s a bug with your naming the taxonomy ‘Locations’ instead of ‘locations’ when you are calling register_taxonomy( 'Locations', 'post', $args );. When I try this locally I get an error when trying to add the locations to the navigation menu as you described.

    Doing a search in the WordPress Trac, I actually see a ticket to resolve this, but it hasn’t been touched in a while. If you feel ambitious enough to create a patch to fix the issue in WordPress core, it could be a good opportunity to get involved. https://core.trac.www.ads-software.com/ticket/16600

    It looks like renaming from ‘Locations’ to ‘locations’ in the code will create a warning on each of the taxonomy terms, so I’d recommend to stick with the workaround with the CPT UI plugin unless you want to recreate the terms and associate them with the data on your site.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fatal error – creating navigation menu for Custom taxonomy’ is closed to new replies.