Recently after updating Wordpress from 4.9.2 to 5.2, I have had to change a good bit of code to get my custom post type listings(or posts) to function and save data correctly. Specifically, with the custom meta boxes I have setup to handle my custom taxonomies(with a select drop down menu) rather than with the default check boxes.

NOTES: I can currently CREATE a new listing, UPDATE a listing, but DELETING the listing I have issues with.

When I go to my listings screen(or Listings custom post type), I try to check multiple check boxes and then click MOVE TO TRASH.

When I move to trash, it gives me the "The link you followed has expired." page. HOWEVER, when I refresh the page to go back to my listings, it appears the listing HAS been moved to the trash, but something is wrong since it shows me the "Link you followed is expired" page.

Any help would be greatly appreciated. This is being developed locally on WAMP, PHP version 7.0.1, Wordpress version 5.2.2 .

TO REVIEW MY CODE, GO TO MY GITHUB AND VIEW THE META_BOXES.PHP FILE. https://github.com/pcross1986/car-dealership

Screenshots below:

enter image description here Listings enter image description here

1 Answer 1


I had one more look at the code and I realized the save function was missing couple of checks. So replace meta_boxes.php:366 with this,

if ( empty( $_POST['nonce_car_details'] ) ) {
check_admin_referer( 'save_car_details_meta', 'nonce_car_details' );
if ( ! current_user_can( 'edit_post', $post_id ) ) {
if ( wp_is_post_autosave( $post_id ) ) {
if ( wp_is_post_revision( $post_id ) ) {

The key thing here is the empty check for nonce. Nonce value is probably not set when the post is trashed, which causes check_admin_referer to fail thus printing the error message. My apologies, this was my bad.

You could also switch to using the post type specific save action so the metabox saving functions gets only fired when the correct post type in question.

add_action('save_post_listings', 'wpt_save_details_meta', 1, 2);

P.S. on custom-taxonomies.php lines 3-29 should probably be inside create_listings_taxonomies() along with the other register_taxonomy calls.

  • 1
    Yes it looks like it works perfectly. Thank you so much!
    – Preston
    Commented Jul 2, 2019 at 19:19
  • @Preston, good to hear. You can mark the answer accepted to let others know that this question has been resolved. Commented Jul 2, 2019 at 19:26
  • I did, but I think my reputation points are low, so it may not get recorded. I guess because I am new to the site.........
    – Preston
    Commented Jul 4, 2019 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.