이 정보를 포스트가 저장되는 최초의 시간을 절약하고 대신 다시 유튜브 API를 사용하여 데이터베이스에서 정보를로드 할 수 post_meta
를 사용할 수 있습니다.
나는 의사 당신에게 예를 넣어 : 당신은 사용자 정의 포스트 유형 queryng 때
add_action('save_post', 'my_function_to_save_posts_action');
function my_function_to_save_posts_action($post_id) {
$the_post = get_post($post_id);
if ($the_post->type == 'my_custom_post_type') {
$youtube_data = my_function_to_retrieve_youtube_data();
if (my_function_exists_post_meta($post_id)) {
update_post_meta($post_id, 'my_video_duration', $youtube_data['duration']);
update_post_meta($post_id, 'my_video_rating', $youtube_data['rating']);
}
else {
add_post_meta($post_id, 'my_video_duration', $youtube_data['duration'], true);
add_post_meta($post_id, 'my_video_rating', $youtube_data['rating'], true);
}
}
}
그리고 물론
, 당신은 post_meta 정보를 PIN이 제대로이 정보를 표시해야합니다.