wp_reset_postdata() trouble with custom post type

Question

I hook 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?
Thanks for any help.

0
SoloCrowd 3 months 0 Answers 26 views 0

Leave an answer