carylwyatt / navbar-tailwind

UA navbar and megamenu as Vue component using TailwindCSS
0 stars 0 forks source link

bug: menu item descriptions disappearing for WP pages #7

Closed carylwyatt closed 4 years ago

carylwyatt commented 4 years ago

In the "menu" admin area, when I attempt to input a description for a menu item being generated from an actual WP page, it doesn't stick. If I update just one (or even several at time), they will update for that one time, but any subsequent "save" of the menu erases the description from the API data and from the database.

This is only happening on menu items that are WP pages, not "custom links." This is only happening with the description, not the icon class or any of the other ACF details.

One stack overflow is suggesting to install a logging plugin to find out what happens when nav_menu_item updates, so I should probably try that.

Query Monitor

carylwyatt commented 4 years ago

I installed that query monitor plugin, and WOW there is a TON going on under the hood!

I started to investigate what's happening when I "save" changes in the Site Navbar menu, but there are so many queries being run that it's hard to filter out all the junk. I'll take a closer look soon!

carylwyatt commented 4 years ago

After messing with the query monitor for a few hours, I decided this is definitely happening after the save button because the data makes it into the API/database on save. BUT the description is then empty when you open the dropdown area after saving... so that leads me to believe there's something up with the theme logic. Maybe the 2020 theme doesn't allow page descriptions in the navbar?

So I went to the "customize theme" area under "Appearance", didn't change a single thing, but when I tried to leave, it gave me this beautiful FATAL ERROR

image

So! Making progress.

carylwyatt commented 4 years ago

I found very few answers on what that error message could be about, but it might be connected to the ACF fields I added to the menu. Sigh.

So! I'm going to deactivate the "description" section on the WP menu side and add it to ACF and see if that will do it.

carylwyatt commented 4 years ago

That solution worked. I decided to try the ACF description box since none of my other custom fields were having any issues with persistence.

I went back to the database and deleted all the "post_content" descriptions for the nav_menu_item post types so hopefully that fatal error will resolve itself at some point.

It seems like maybe it won't though? The answers in this stack exchange post seem to think the fatal error is being caused by deleting a menu item that has ACF fields attached to it... I'm sure I deleted a few menu items as I was figuring things out. I might need to go back and wipe out the extra data to get around that, but that won't solve the problem going forward.

Maybe I'll need to add some kind of hook to my eventual solution for getting this in our theme? Like a "if menu item deleted, delete all associated ACF fields" kind of thing. I'll add it to the github issue.