Sunday, October 30, 2022
HomeWordPress Developmentposts - How can I exploit wp_after_insert_post with $current_screen?

posts – How can I exploit wp_after_insert_post with $current_screen?


I might prefer to name add_action( 'wp_after_insert_post' on specific screens. I am at the moment checking the web page like so adopted by calling the wp_after_insert_post hook. It would not appear to fireplace however does if it is swapped with add_action( 'current_screen', 'take a look at' ); as an alternative.

perform take a look at() {
    world $current_screen;

    if ( isset( $current_screen->base ) ) {
        if ( $current_screen->id == 'put up' ) {

            $args = array(
                'ID'          => '10',
                'post_name'   => 'Some title',
            );
                        
            // Replace the put up
            wp_update_post( $args );
        }
    }
}
add_action( 'wp_after_insert_post', 'take a look at', 100 );

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments