admin管理员组文章数量:1134579
I am building a WordPress
plugin the sets the post_parent
of a post to the id of a custom post type called series. However, once I click update
on the post it successfully updates the post and the next request hangs for 40 seconds on my laptop and never loads on my PC even if I reload or open a new tab. On my PC I have to restart Apache
to fix it. Here is relevant the code:
/**
* Saves part of which series the post is.
*
* @param $post_id
* @param $post
* @return mixed
*/
function elegant_series_save_post_series_select_meta($post_id, $post) {
/* Verify the nonce before proceeding. */
if ( !isset( $_POST['elegant_series_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['elegant_series_meta_box_nonce'], 'save-elegant-series-meta-box' ) ) {
return $post_id;
}
/* Get the post type object. */
$post_type = get_post_type_object( $post->post_type );
/* Check if the current user has permission to edit the post. */
if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
return $post_id;
/* Get the posted data and sanitize it for use */
$series_id = ( isset( $_POST['elegant-series-select-series'] ) ? absint( $_POST['elegant-series-select-series'] ) : '' );
elegant_series_add_post_to_series($post_id, $series_id);
}
function elegant_series_add_post_to_series($post_id, $series_id)
{
wp_update_post(
[
'ID' => $post_id,
'post_parent' => $series_id
]
);
}
could this be due to having a lot of posts - I have about ~2500.
I tried googling various things but did not find anything.
本文标签: pluginsUpdating postparent caused the website to become unresponsive for 40 seconds or more
版权声明:本文标题:plugins - Updating post_parent caused the website to become unresponsive for 40 seconds or more 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736862101a1955960.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论