admin管理员组文章数量:1391977
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.
本文标签: functionsUrgentWordPress keeps creating posts
版权声明:本文标题:functions - Urgent - WordPress keeps creating posts 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744682023a2619468.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论