What I'm trying to do is to delete some post from a custom post type bookitall_availabledate after a post is deleted from custom post type bookitall_bookings in the admin dashboard.

I'm using delete_post hook: https://codex.wordpress.org/Plugin_API/Action_Reference/delete_post

Here's some relevant code: (tell me if you need more)

public function __construct() 
        add_action( 'init', array( $this, 'loadlanguage' ) );

public function loadlanguage() 
    wp_enqueue_script( 'jquery' );        

        plugins_url( '/css/wibergsweb.css', __FILE__)

    //Load (if there are any) translations
    $loaded_translation = load_plugin_textdomain( 'bookitall-wp', false, 
    dirname( plugin_basename(__FILE__) ) . '/lang/' );

public function admin_init() {

    add_filter('manage_edit-bookitall_bookings_columns', array($this, 'manage_allbookings_columns') );
    add_filter('manage_bookitall_bookings_posts_custom_column', array( $this, 'manage_allbookings_custom_fields'), 10, 2);

    add_filter('manage_edit-bookitall_roomtypes_columns', array($this, 'manage_allroomtypes_columns') );
    add_filter('manage_bookitall_roomtypes_posts_custom_column', array( $this, 'manage_allroomtypes_custom_fields'), 10, 2);

    add_filter('manage_edit-bookitall_customers_columns', array($this, 'manage_allcustomers_columns') );
    add_filter('manage_bookitall_customers_posts_custom_column', array( $this, 'manage_allcustomers_custom_fields'), 10, 2);        

    add_filter('manage_edit-bookitall_available_columns', array($this, 'manage_allavailable_columns') );
    add_filter('manage_bookitall_available_posts_custom_column', array( $this, 'manage_allavailable_custom_fields'), 10, 2);        

    add_action( 'delete_post', array( $this, 'bookings_sync', 10 ) );


//When removing a post from post type bookitall_bookings (bokningar)
public function bookings_sync ( $post_id ) {
    $post_type = get_post_type( $post_id );   
    if ( $post_type != 'bookitall_bookings' ) 

    //more code...

The issue is that function bookings_sync is not being fired? (wp_die('wow') should kill Wordpress and exit everything?)

I've also tried with admin_init hook instead of init hook but still the same issue.

I've also tried deleting the post permanently from trash but still does not work.

Am I using wrong hook or what is going on? Help me please :-)

1 Answer 1


I've actually found it. "Just" a typo...

add_action( 'delete_post', array( $this, 'bookings_sync', 10 ) );

should be

add_action( 'delete_post', array( $this, 'bookings_sync'), 10 );

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.