wp_reset_postdata() trouble with custom post type


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


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.

SoloCrowd 2 years 2020-11-02T15:10:46-05:00 0 Answers 26 views 0

Leave an answer