I was trying to create a WordPress function that altered the post_name. My final function is:
function edit_permalink( $post_id ) {
if ( 'ratings' === get_post_type( $post_id ) ) {
remove_action( 'save_post', 'edit_permalink' );
$slug = get_post_field('post_title', $post_id);
$slug = urlencode($slug);
$date = get_field( 'date_of_rating', $post_id );
$location = wp_get_post_terms( $post_id, 'areas' );
wp_update_post(array('ID' => $post_id, 'post_name' => $slug . "_" . $date->name . "_" . $location[0]->slug));
add_action( 'save_post', 'edit_permalink' );
}
}
add_filter( 'save_post', 'edit_permalink', 10, 2 );
HOWEVER - somewhere along the way, I created a function that is just spewing out multiple posts every second. I'm now up 4000 - still going on - and I can't stop it!! I've tried switching themes, wp_die() - what else can I do!?!
I was trying to create a WordPress function that altered the post_name. My final function is:
function edit_permalink( $post_id ) {
if ( 'ratings' === get_post_type( $post_id ) ) {
remove_action( 'save_post', 'edit_permalink' );
$slug = get_post_field('post_title', $post_id);
$slug = urlencode($slug);
$date = get_field( 'date_of_rating', $post_id );
$location = wp_get_post_terms( $post_id, 'areas' );
wp_update_post(array('ID' => $post_id, 'post_name' => $slug . "_" . $date->name . "_" . $location[0]->slug));
add_action( 'save_post', 'edit_permalink' );
}
}
add_filter( 'save_post', 'edit_permalink', 10, 2 );
HOWEVER - somewhere along the way, I created a function that is just spewing out multiple posts every second. I'm now up 4000 - still going on - and I can't stop it!! I've tried switching themes, wp_die() - what else can I do!?!
Share Improve this question asked Mar 10, 2020 at 13:05 JohnGJohnG 3443 silver badges17 bronze badges 1- I've reverted the functions file, incidentally, but it's still creating posts. 4400... – JohnG Commented Mar 10, 2020 at 13:08
1 Answer
Reset to default 0If you have access to the server's list of PHP processes, you can try killing them or restarting the PHP server.
Otherwise, your script might hit a "maximum execution time" limit sometime soon (unless set to inifinite). The setting in question is called max_execution_time and is expressed in seconds if you can access your server's configuration.