我无法升级我的function.php以便:
检查是否有草稿
如果有内容,标题和类别
如果有一个title = post_category的页面升级页面的内容 使用post_content(和post_title)
否则创建一个title = post_category和content = post_content and post_title
的页面代码
add_action( 'wp_insert_post', 'privatepostcheck' );
function privatepostcheck(){
$args = array(
'post_type' => 'post',
'post_status' => 'draft'
);
// get the draft post
$posts_array = get_posts( $args );
foreach($posts_array as $post){
// foreach draft post get title, content and category
$posttext = get_the_content($post);
$postcate = get_the_category($post);
$postitle = get_the_title($post);
//check if there is page with name = post category
//get the page
$page = get_page_by_title( $postcate );
//get content
$content_page = apply_filters('the_content', $page ->post_content);
$content_post = apply_filters('the_content', $post->post_content);
$page = array(
'post_content' => "asidasoidjasoidjsaoi<br>".$content_page,
);
wp_update_post( $page );
}