2012-10-09 2 views
3

나는 클라이언트 용으로 구축중인 Wordpress 사이트의 Post Array와 관련하여 혼란 스럽습니다. 나는 누군가가 전에 이것을 보았 으면 좋겠다!관리자 패널의 Wordpress Post Array에서 이상한 문제가 발생했습니다.

나는 다음과 같은 메타 상자 콜백을 등록하는 내
register_post_type('products', array(
    'labels' => array(
     'name' => __('Products'), 
     'singular_name' => __('Product'), 
    ), 
    'public' => true, 
    'menu_position' => 20, 
    'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments',), 
    'taxonomies' => array('category'), 
    'capability_type' => 'post', 
    'rewrite' => array('slug' => 'products','with_front' => TRUE), 
    'register_meta_box_cb' => 'product_page_meta_box' 
)); 

:

function product_page_meta_box() { 
    add_meta_box('product_meta_box_content', 'Product Specifications', 'product_meta_box_content', 'products'); 
} 

function product_meta_box_content($post) { 

    wp_nonce_field(plugin_basename(__FILE__), 'product_noonce'); 

    echo '<div class="inside>'; 
     var_dump($post); 
     echo '<p>Please detail the product specifics here:</p>'; 
    echo '</div>'; 
} 

내가 가진 불만은 위해서 var_dump의 결과이다

나는 사용자 정의 포스트 유형을 등록 위의 관리자 페이지는 다음과 같습니다.

string(3) "258" ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2012-08-27 19:33:30" ["post_date_gmt"]=> string(19) "2012-08-27 19:33:30" ["post_content"]=> string(0) "" ["post_title"]=> string(10) "The Wensum" ["post_excerpt"]=> string(20) "Testing the excerpt!" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(22) "large-6-perch-dovecote" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2012-10-04 16:50:19" ["post_modified_gmt"]=> string(19) "2012-10-04 16:50:19" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> string(1) "0" ["guid"]=> string(53) "http://dovecotes.local//?post_type=products&p=258" ["menu_order"]=> string(1) "0" ["post_type"]=> string(8) "products" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["ancestors"]=> array(0) { } ["filter"]=> string(4) "edit" } 

관리자 영역에는 유형이없고 공동 완전히 무효하다. 포스트 배열이 괜찮습니다하지만 해당 페이지에서 ID는 키를 가지고 있으며, 그것은 유효한 객체입니다

object(stdClass)#145 (25) { ["ID"]=> int(258) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2012-08-27 19:33:30" ["post_date_gmt"]=> string(19) "2012-08-27 19:33:30" ["post_content"]=> string(0) "" ["post_title"]=> string(10) "The Wensum" ["post_excerpt"]=> string(20) "Testing the excerpt!" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(22) "large-6-perch-dovecote" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2012-10-04 16:50:19" ["post_modified_gmt"]=> string(19) "2012-10-04 16:50:19" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(54) "http://dovecotes.local//?post_type=products&p=258" ["menu_order"]=> int(0) ["post_type"]=> string(8) "products" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["ancestors"]=> array(0) { } ["filter"]=> string(3) "raw" } 

답변

0

나는이 작동 보장 할 수 없습니다,하지만 난 항상 'register_meta_box_cb를 사용하여 피했다 'add_meta_boxes'액션 훅을 위해 사용자 정의 포스트 유형을 정의 할 때.

'지원'매개 변수의 여분의 쉼표를 제외하고 코드가 올바르게 보이므로 예제의 어떤 것도 그것이 우선 순위 불일치가 아니라면 그 어떤 것도 범인이 될 수 있다고 생각하게됩니다. 나는 또한 ID와 콜백 매개 변수는 사용자의 METABOX 인수에서 동일 할 수있는 경우하지 않도록, 그래서 나는 그것도 변경의 자유를했다 : 난 후,

register_post_type('products', array(
    'labels' => array(
     'name' => __('Products'), 
     'singular_name' => __('Product'), 
    ), 
    'public' => true, 
    'menu_position' => 20, 
    'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments'), 
    'taxonomies' => array('category'), 
    'capability_type' => 'post', 
    'rewrite' => array('slug' => 'products','with_front' => TRUE) 
)); 
add_action('add_meta_boxes', 'product_page_meta_box'); 
function product_page_meta_box() { 
    add_meta_box('product_meta_box_content', 'Product Specifications', 'product_meta_box_content_cb', 'products'); 
} 

function product_meta_box_content_cb($post) { 

    wp_nonce_field(plugin_basename(__FILE__), 'product_noonce'); 

    echo '<div class="inside>'; 
     var_dump($post); 
     echo '<p>Please detail the product specifics here:</p>'; 
    echo '</div>'; 
} 

가 도움이되지 않는 경우 더 많은 코드를 보지 않으면 무엇이 될지 확신 할 수 없습니다.

+0

안녕하세요, 답장을 보내 주셔서 감사합니다. @ maiorano84. 두 가지 방법으로 시도해 보았지만 불행히도 결과는 동일합니다. 어떤 코드가 도움이 될 것이라고 생각하십니까? – Illizian

+0

죄송합니다. 콜백과 관련된 부분을 놓친 경우 ID가 잠시 후이를 변경하고 도움이되는지 알려드립니다! – Illizian

관련 문제