我正在努力研究如何在帖子状态发生变化后更改其详细信息。
我想通过添加帖子id号来更改帖子的标题。下面是我现在正在使用的代码,但它不会更改帖子的标题:
function update_post_info( $post_id, $post, $update ) {
// Stop anything from happening if revision
if ( wp_is_post_revision( $post_id ) ) return;
//get post type
$post_type = get_post_type($post_id);
// If this isn\'t a custom post, don\'t update it.
// if ( "cbre_access_form" != $post_type ) return;
//run codes based on post status
$post_status = get_post_status();
if ( $post_status != \'draft\' )
{
if ( isset( $_POST[\'post_title\'] ) ) {
//stuck on this part not changing post title
$ppt = \'test title - \'.$post_id;
update_post_meta( $post_id, \'post_title\', $ppt );
}
}
}
add_action( \'save_post\', \'update_post_info\', 10, 3 );