Wordpress get post content and upgrade a page -


i stuck upgrade function.php in order to:

check if there draft post

if there content, title , category

if there page title = post_category upgrade content of page post_content(and post_title)

else create page title = post_category , content = post_content , post_title

the code

add_action( 'wp_insert_post', 'privatepostcheck' );  function privatepostcheck(){      $args = array(               'post_type' => 'post',               'post_status' => 'draft'               );     // draft post              $posts_array = get_posts( $args );      foreach($posts_array $post){         // foreach draft post title, content , category         $posttext = get_the_content($post);         $postcate = get_the_category($post);         $postitle = get_the_title($post);             //check if there page name = post category         //get 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 ); } 


Comments