Thursday, October 27, 2022
HomeWordPress DevelopmentCustomized Put up-Rename Perform Does Not Perform in WordPress 6.x

Customized Put up-Rename Perform Does Not Perform in WordPress 6.x


I’ve the next perform in capabilities.php in a baby theme:

<?php
add_filter( 'wp_insert_post_data' , 'modify_post_title' , '99', 1 ); // Grabs the inserted publish knowledge so you'll be able to modify it.
perform modify_post_title( $knowledge ){
    if($knowledge['post_type'] == 'publish' || $knowledge['post_type'] == 'comment' || $knowledge['post_type'] == 'share' && !get_page_by_title($knowledge['post_title'],OBJECT, 'publish')){
        $id = get_the_ID();
        $new_title = get_the_time( 'Y-m(M)-d(D)—HiT', $id );
        $new_slug = get_the_time( 'Y-m-d-HiT', $id );

        $knowledge['post_title'] =  $new_title;
        $knowledge['post_name'] = strtolower($new_slug); // Updates the publish slug to the brand new title.
    }
    return $knowledge;
}

What this ought to do is seize the (publish) date and time and set that to the title and slug for the listed publish varieties. This labored exactly as anticipated till lately. For some motive, this perform now not works in WordPress 6.x (as of penning this, WordPress 6.0.3).

Nothing related appears to seem in any logs. What change or modifications induced this to interrupt? and what must be up to date to get it working once more?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments