Trouble with wp_reset_postdata() in Admin Panel
I'm hooking into 'edit_form_after_editor'
add_action('edit_form_after_editor', 'make_the_button_to_generate_a_report_number');
function make_the_button_to_generate_a_report_number($post) {
Check that I am dealing with a custom post type of 'publications'
if ($post-post_type != 'publications') return;
Create a number of arguments that I then run in a WP_Query
$new_query = new WP_Query($report_number_args);
use that data to do stuff...
Then I want to reset $post
back to how it was, so I run
wp_reset_postdata();
But $post
stays on the last item I had received from my new WP_Query().
What am I doing wrong? Is there a special way to reset the postdata when dealing with a custom post type?
Update: At the beginning and end of the function I have:
echo(h4the title = /h4);
echo(the_title());
At the beginning the title is the title for the custom post type I clicked on to edit, or blank if I am creating a new post. At the end the title is always the last post from my query.
Topic wp-reset-postdata wp-query admin Wordpress
Category Web