• Hello,

    Im trying to delete a post of a custom post type.

    When I use wp_delete_post, it removes the post but returns Unexpected ”.

    I debugged the code and I found the problem in this line: do_action( ‘delete_post’, $postid ) of wp_delete_post function.

    Can you please help me?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Can you paste the part of the code where you use wp_delete_post?

    Thread Starter sent09

    (@sent09)

    Fixed,

    the problem was in other function…

    function it_redirect_after_delete_post() {
        
    	global $post;
    
      if ( $post ) { // <---- This if wasn't here and it returns the error
        
        $post_type = $post->post_type;
        if ( 'reservas_lentillas' == $post_type ) {
          wp_redirect( get_admin_url() . '/edit.php?post_type=' . $post_type );
        }
          
        exit;
      }
    
    }
    add_action( 'deleted_post', 'it_redirect_after_delete_post' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_delete_post Unexpected ”’ is closed to new replies.