Trigger refresh of admin menu

Apologies if this isn’t an appropriate question for the forum, I’m new to wordpress development and needed to bring this question to some experts.

I’ve written a plugin that creates custom post types. Currently, I’ve created a menu page with add_menu_page. I’ve hooked this to a function that creates a page that includes a form to add a custom post type.

When the user submits the form, the page inside the admin dashboard refreshes. However, I have to manually refresh the page to see the new custom post type appear in my admin menu!

I’d like to force a refresh of the entire admin dashboard (including the left side admin menu panel) but I don’t fully understand if I can trigger an action from the client or how I can use javascript effectively to do so.

I’ve tried embedding JavaScript on the form submit button:

Read more here:: Trigger refresh of admin menu

Leave a Reply

Your email address will not be published. Required fields are marked *