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!
<input type="submit" onclick="window.location.reload()" but this doesn't work and comes with wierd consequences like event bubbling when focusing on the form.
I've tried using
admin_menu action hooks combined with echoing
http-equiv="refresh" .. and
header('Location: '.$_SERVER[ 'HTTP_REFERER' ]) in my php code but this either causes infinite loops, being unable to switch to the backend because of
Location: $_SERVER[ ... ] of my dashboard, or refreshing every second due to
location.reload() but this also doesn't have to the expected result (it doesn't reload the entire page, only the menu page itself).
Is there a simple way to trigger an admin menu refresh? I feel like I need to init another WordPress rerender somehow.
It could be the placement/location in the code to some of these calls to refresh the page are misplaced.
Here's a link to my code on github: https://github.com/songfarm-david/Peak-Custom-Post-Types
Here's a similar question with some of the solutions I've talked about: Refresh page after form action
Link to similar question: Refresh Taxonomies
Thanks in advance,