• Resolved aut0poietic

    (@aut0poietic)


    I have a couple of questions regarding wp_delete_post based on some behavior I’m seeing in developing a plugin.

    After validating that I have a valid document of type ‘event’ (custom post type) I call the following:

    wp_delete_post( $row->event_id , false ) ;

    My assumption is that this should either mark the item as ‘trash’ or delete it if it is already marked trash, firing all actions along the way.

    This doesn’t seem to be happening. When I call this for a custom post type, the ‘event’ is deleted. Checking the code for wp_delete_post, shows that it will only trash ( $post->post_type == 'post' || $post->post_type == 'page') — everything else is deleted.

    This is obviously not the behavior when you click ‘move to trash’ using the WP Admin UI.

    So first question is: Is this a bug in wp_delete_post and should I report it (and where…)?

    Next, looking in wp_delete_post shows me a function wp_trash_post. Looks like just the ticket for what I want, however it is not listed in the codex, and Googling turns up almost no documentation. While it is prefixed with a “wp_” leads me to believe it is public, because there is no documentation I worry about this breaking in a future WP release.

    Next question is: Is this just a missing documentation entry or should I avoid this method like the plague? If it is a case of the documentation missing, is it possible for me to add the entry?

    Thanks for reading this book :-X

Viewing 2 replies - 1 through 2 (of 2 total)
  • You want wp_trash_post. It’s a fairly new addition to the codebase, since 2.9. wp_delete_post is older and a little clumsier, so it probably doesn’t handle the custom post types too well.

    PS: Just missing documentation. You should be able to add the entry, yes. =)

    Thread Starter aut0poietic

    (@aut0poietic)

    rjmastey,

    Good to know I’m on the right track and not just missing the obvious. Once I get this plugin cleaned up I’ll see if I can create the codex entry, and possibly submit this as a bug in trax.

    Thanks for the info.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_delete_post / wp_trash_post’ is closed to new replies.