我编写了一个函数,可以在页面中插入内容,并且每个日期都会自动更新。
我用过wp_update_post( $my_post );
更新页面。
我想先在顶部特定的页面中插入内容,然后更新,但它不起作用。
它只是更新或插入内容。。
function wp_emallmobnok(){
$postdater = parsidate(\'j / F / Y\',$datetime=\'now\',$lang=\'pre\');
$postdate = date(\'Y-m-d H:i:s\');
$ta = parsidate(\'j / F / Y\',$datetime=\'now\',$lang=\'pre\');
$postdate_gmt = date(\'Y-m-d H:i:s\');
$titles="price daily";
$posts = array(
\'post_content\' => $oiobz1,
\'post_name\' => $titles,/// The page url name
\'ID\' => 225, /// The page id witch we want to update that
\'post_title\' => $titles,
\'post_type\' => \'page\',
\'post_status\' => \'publish\',
\'post_author\' => \'6\',
\'ping_status\' => \'open\',
\'post_date\' => $postdate_gmt,
\'post_category\' => array(188),
\'tags_input\' => " price",
);
$post_id = wp_insert_post($posts);//// instert post
add_post_meta( $post_id, \' wp_insert_post\', 0, true );
$post_up = wp_update_post($posts);///update post
add_post_meta( $post_id, \' wp_update_post\', 0, true );
}