간단한 PHP 파일을 사용하여 내 WordPress에 게시하고 있습니다. 지금까지 900posts 정도가 있지만 아직 게시 시간이 오래 걸리는 것으로 나타났습니다! 그것은 어느정도 (심지어 30 초 +) 다 떨어집니다! 여기 내가 사용하는 코드입니다. wordpress wp_insert_post가 너무 오래 걸립니다.
<?php
require_once('./../wp-blog-header.php');
require_once('./simple_html_dom.php');
require_once('./../wp-admin/includes/taxonomy.php');
function postit($category,$date,$title,$content,$keys){
$cat=wp_create_category($category);
$post = array(
'comment_status' => 'open',// 'closed' means no comments.
'ping_status' => 'open', // 'closed' means pingbacks or trackbacks turned off
'post_author' => '1', //The user ID number of the author.
'post_category' => array($cat), //post_category no longer exists, try wp_set_post_terms() for setting a post's categories
'post_content' => $content, //The full text of the post.
'post_date' => date('Y-m-d H:i:s',strtotime($date)), //The time post was made.
'post_date_gmt' => date('Y-m-d H:i:s',strtotime($date)), //The time post was made, in GMT.
'post_status' => 'publish', //Set the status of the new post.
'post_title' => $title, //The title of your post.
'post_type' => 'post', //You may want to insert a regular post, page, link, a menu item or some custom post type
'tags_input' => $keys,//For tags.
'post_content_filtered' => '1',
'filter' => '1'
);
remove_filter('content_save_pre', 'wp_filter_post_kses');
remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
$r=wp_insert_post($post ,$wp_error);
add_filter('content_save_pre', 'wp_filter_post_kses');
add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
return $r;
}
내가 프로파일이를 실행
,wp_create_category 0.01 초를 실행합니다. 그리고 나머지 코드는 0.8 초가 걸리는 반면 필터와 wp_insert_post를 제거하는 부분은 나머지 실행 시간이 걸립니다 ..
누구나 이것을 최적화 할 수있는 제안이 있습니까?
대시 보드에서도 여전히 이러한 현상이 발생합니까? –
@RobertLee 대시 보드의 경우 동일합니다 – Zalaboza
데이터베이스를 최적화하려고 시도 했습니까? 당신이 할 수있는 수동 질의가 있지만 이것은 좀 더 사용하기 쉽습니다. http://wordpress.org/extend/plugins/tentblogger-optimize-wordpress-database-plugin/ –