3
내 워드 프레스 게시물 편집 페이지에 맞춤 메타 박스를 추가하려고합니다. 상자에 (비디오 URL)을 추가했지만 설정 값으로 필드에서 게시물 정보를 표시하려고 시도하면 아무 것도 표시되지 않습니다. 나는 그것을 올바르게 저장하고 있다고 믿지만 구원받은 후에 보여주기 위해 얻을 수 없다. 제발 도와주세요. 아래 그림과 같이 I 사용자 정의 플러그인으로 모든 코드를 이동 끝내었고, 작업 그것을 가지고게시물 편집 페이지에 맞춤 메타 박스 값을 표시 할 때의 문제점
<!-- adding the video url meta box prototype data -->
<?php
add_action('add_meta_boxes', 'cd_meta_box_add');
function cd_meta_box_add()
{
add_meta_box('post-video', 'Video URL', 'video_url_meta_box', 'post', 'side', 'high');
}
?>
<!-- rendering the video url meta box on the post edit page -->
<?php
function video_url_meta_box($post)
{
$value = get_post_meta($post->ID, 'video_url_text', true);
wp_nonce_field('video_url_nonce', 'meta_box_nonce');
?>
<p>
<label for="video_url_text">Youtube or Vimeo URL</label>
<input type="text" name="video_url_text" id="video_url_text" value="<?php echo $value; ?>" />
</p>
<?php
}
?>
<!-- Saving the video url meta box data -->
<?php
add_action('save_post', 'video_url_save');
function video_url_save($post_id)
{
//return if we're doing an auto save
if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
//return if we can't verify nonce or it isn't there
if(!isset($_POST['video_url_nonce']) || !wp_verify_nonce($_POST['meta_box_nonce'], 'video_url_nonce')) return;
//return if the current user can't edit the post
if(!current_user_can('edit_page')) return;
// save data once all checks are passed
// make sure the url is set
if(isset($_POST['video_url_text']))
update_post_meta($post_id, 'video_url_text');
}
?>