Skip Navigation

[Resolved] I try to delete a item of a custom post type by code

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by Joan 6 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#912335

In a Post form I create a item of a custom post type. I have added some code triggered by the "cred_save_data" hook. It works fine. Too I try to move to trash a item on another custom post type in the same hook. I make a query with WP_Query() and after found the id i try to move to trash it with wp_trash_post().

I get the a ID of the CPT item to delete but it is not moved to trash.

Is this approach correct?

Thanks in advance.

#912490

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Joan,

Thank you for contacting our support forum.

Is it that you want to delete the post after another post is saved?

Please let me know.

Thanks,
Shane

#912506

No, after the post is created and saved on the CRED form I want to delete another post of a different custom post type.

Thanks,

Joan

#912569

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Joan,

Could you send me the code that you are using to do this ?

Thanks,
Shane

#912917

Hi Shane,

I found the error on the code. It works fine now.

I'm sorry for the inconvenience.

Thanks,

Joan