当像这样使用它时:
add_post_meta($post_ID, 'Name', "Bob", true );
工作正常,但是当将字符串值存储在变量中时,例如:
$name = "Bob";
add_post_meta($post_ID, 'Name', $name, true ); // <---- This doesn't work.
请帮忙。谢谢。
当像这样使用它时:
add_post_meta($post_ID, 'Name', "Bob", true );
工作正常,但是当将字符串值存储在变量中时,例如:
$name = "Bob";
add_post_meta($post_ID, 'Name', $name, true ); // <---- This doesn't work.
请帮忙。谢谢。
试试下面的代码。
$name = "Bob";
update_post_meta($post_ID, 'Name', $name );
$latestVideo = wp_get_recent_posts(array(
'numberposts' => 1,
'post_type' =>'video',
'post_status' => 'publish'
));
$latestVideoWeek = get_post_meta( $latestVideo[0]["ID"], "Week", true);
$latestVideoDate = get_post_meta( $latestVideo[0]["ID"], "Date", true);
function meta_info_video( $post_ID ) {
add_post_meta( $post_ID, 'Semana', $latestVideoWeek, true );
add_post_meta( $post_ID, 'Fecha', $latestVideoDate, true );
add_post_meta( $post_ID, 'URL', '0', true );
}
add_action( 'draft_video', 'meta_info_video' );