或者将其封装在函数中:
function meta_value_exists($your_meta_value) {
$args = array(
\'post_type\' => \'YOUR_POST_TYPE\',
\'post_status\' => \'publish\',
\'numberposts\' => 1,
\'meta_key\' => \'your_meta_field\',
\'meta_value\' => $your_meta_value,
);
$current_post = get_posts($args);
if( $current_post ) {
return true;
} else {
return false;
}
}
因此,您可以检查您的元值:
$video_id = 1234;
if(meta_value_exists($video_id){
// do something if exists
} else {
// do something if not exists
}