이것은 모두 내 코드입니다 .... 아마 내가 뭔가 잘못 저장 기능이 작동하지 않습니다 원인 않았다. 나는 어디서 어떻게 실수를 했는가. 나는 라디오 스트리밍에 대한 세부 사항을 가지고 다중 아이템과 또 다른 메타 보크로 스피커 선택을 위해 CPT와 메타 보스를 만들었을 것이다. 아마도 나는 많은 meta_boxes를 사용했다. .. 난 나를Wordpress 저장 metabox dara가 작동하지 않습니다
<?php
add_action('init', 'speaker_manager');
function speaker_manager() {
$labels = array(
'name' => __('Speakers'),
'singular_name' => __('speaker'),
'add_new' => __('Aggiungi Speaker'),
'add_new_item' => __('Nuovo Speaker'),
'edit_item' => __('Modifica Speaker'),
'new_item' => __('Nuovo Speaker'),
'all_items' => __('Elenco Speaker'),
'view_item' => __('Visualizza '),
'search_items' => __('Cerca '),
'not_found' => __('Speaker non trovato'),
'not_found_in_trash' => __('Speaker non trovato nel cestino'),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_ui' => true,
'rewrite' => array('slug' => 'speaker'),
'publicly_queryable' => true,
'has_archive' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_icon' => get_stylesheet_directory_uri() . '/images/speakers.png',
'menu_position' => 5,
'supports' => array(
'title',
'editor',
'thumbnail'
),
);
register_post_type('speaker', $args);
}
if (function_exists('add_theme_support')) {
add_theme_support('post-thumbnails');
set_post_thumbnail_size(220, 150);
}
add_action("admin_init", "speaker_manager_add_meta");
function speaker_manager_add_meta(){
add_meta_box("speaker-meta", "Social", "speaker_manager_meta_options", "speaker", "normal", "high");
}
function speaker_manager_meta_options($post)
{
?>
<p>Aggiungi i profili social:</p>
<p><label for="speaker_social_link">Link al sito</label>
<input type="text" id="speaker_social_link" name="speaker_social_link"
value="<?php echo get_post_meta($post->ID, 'speaker_social_link', true); ?>"/></p>
<?php
}
add_action('save_post', 'save_speaker_social_link');
function save_speaker_social_link($post_id)
{
global $post;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
//if you remove this the sky will fall on your head.
return;
}else{
update_post_meta($post_id, 'speaker_social_link', esc_url($_POST['speaker_social_link']));
}
}
add_filter('manage_speaker_posts_columns', 'columns_speaker');
function columns_speaker($old_columns)
{
$speaker_col = array(
'cb' => '<input type="checkbox">',
'img' => 'Immagine',
'title' => __('Speakers'),
'link' => 'link',
);
return $speaker_col;
}
add_action('manage_speaker_posts_custom_column', 'get_speaker_columns', 10, 2);
function get_speaker_columns($col, $post_id)
{
switch($col) {
case 'img':
if(has_post_thumbnail($post_id)) {
echo get_the_post_thumbnail($post_id);
} else {
echo 'Nessuna immagine!';
}
break;
case 'link':
echo get_post_meta($post->ID, 'speaker_social_link', true);
default:
break;
}
}
코드를 논리적으로 들여 쓰면 코드가 훨씬 쉽게 *** 사용할 수 있습니다. – brasofilo
올바른 구문을 따르고 있습니까? php update_post_meta ($ post_id, $ meta_key, $ meta_value, $ prev_value); ?>'코드 포스트 ID가 $ post_id이면 $ meta_key는 'speaker_id'이고 $ meta_value는 $ _POST [ 'speaker_id']입니다. 하지만 당신은 어떤 speaker_id라는 이름의 폼 필드를 가지고 있지 않습니다. schdule_dj-start에서 작동하고 전송해야합니다. if 문을 검사하고 error_log(); 저장 함수가 post_id를 얻는 지 확인하십시오. 어디에서 코드'add_action ('admin_menu', 'palinsesto_box');'? –
@b__ 내가 한 일은 ... 당신이 나를 도울 수 ... 내 사용자 정의 열에서 링크를 볼 수 없습니다 – zen