Why are navigation items saved in the database?

Maybe I am just not grasping the concept of WP right here but why is everything in WordPress stored as a post of some type? I have a custom set of tables that house hundreds and thousands of items. I would like to programatically create a navigation menu that dynamically updates items to reflect my custom tables. I haven’t been able to find a way to do this without using the following function:

wp_update_nav_menu_item()

To my understanding this function stores the item in the array in the wordpress tables as posts/taxonomies? This is needless overhead in my case and looks pretty permanent. My menu items will change pretty much on a daily basis, I don’t want to grab items from one table only to have them stored in another table.

Does anyone know how I could directly update the navigation menu each time the homepage loads without requiring any interference from the administration panel?

Thanks.

1 Answer
1

Filter wp_nav_menu_objects and add your custom items dynamically (see this example or this). You get the current list of items and the arguments wp_nav_menu() was with as parameters. Then you can just add new items or remove existing ones.

Leave a Comment