2017-10-29 3 views
0

내가 만든 cutom 플러그인을 통해 슬러그 plist으로 CPT를 만들었습니다.사용자 정의 게시 유형 아카이브 페이지가 비어 있습니다.

내 로컬 호스트에서 아카이브가 작동하지만 라이브 서버에서는 빈 페이지가 반환됩니다.

http://cratetimer.com/plist/는 또한이 도움이 될 수 :

/** 
* Register Custom Post Type Price List 
* @since 1.0.0 
*/ 
if (! function_exists('price_item_post_type')) { 
    add_action('init', 'price_item_post_type', 0); 
    // Register Custom Post Type 
    function price_item_post_type() { 

     $labels = array(
      'name'     => _x('Price Lists', 'Post Type General Name', 'plist'), 
      'singular_name'   => _x('Price List', 'Post Type Singular Name', 'plist'), 
      'menu_name'    => __('Price List', 'plist'), 
      'name_admin_bar'  => __('Price List', 'plist'), 
      'archives'    => __('Price List Archives', 'plist'), 
      'attributes'   => __('Price List Attributes', 'plist'), 
      'parent_item_colon'  => __('Parent Price List:', 'plist'), 
      'all_items'    => __('All Price Lists', 'plist'), 
      'add_new_item'   => __('Add New Price List', 'plist'), 
      'add_new'    => __('Add New', 'plist'), 
      'new_item'    => __('New Price List', 'plist'), 
      'edit_item'    => __('Edit Price List', 'plist'), 
      'update_item'   => __('Update Price List', 'plist'), 
      'view_item'    => __('View Price List', 'plist'), 
      'view_items'   => __('View Price Lists', 'plist'), 
      'search_items'   => __('Search Price List', 'plist'), 
      'not_found'    => __('Not found', 'plist'), 
      'not_found_in_trash' => __('Not found in Trash', 'plist'), 
      'featured_image'  => __('Featured Image', 'plist'), 
      'set_featured_image' => __('Set featured image', 'plist'), 
      'remove_featured_image' => __('Remove featured image', 'plist'), 
      'use_featured_image' => __('Use as featured image', 'plist'), 
      'insert_into_item'  => __('Insert into Price List', 'plist'), 
      'uploaded_to_this_item' => __('Uploaded to this Price List', 'plist'), 
      'items_list'   => __('Price Lists', 'plist'), 
      'items_list_navigation' => __('Price Lists navigation', 'plist'), 
      'filter_items_list'  => __('Filter Price Lists', 'plist'), 
     ); 
     $args = array(
      'label'     => __('Price List', 'plist'), 
      'description'   => __('Price list item for market', 'plist'), 
      'labels'    => $labels, 
      'supports'    => array(), 
      'hierarchical'   => false, 
      'public'    => true, 
      'show_ui'    => true, 
      'show_in_menu'   => true, 
      'menu_position'   => 20, 
      'menu_icon'    => 'dashicons-tag', 
      'show_in_admin_bar'  => true, 
      'show_in_nav_menus'  => true, 
      'can_export'   => true, 
      'has_archive'   => true,   
      'exclude_from_search' => true, 
      'publicly_queryable' => true, 
      'capability_type'  => 'page', 
     ); 
     register_post_type('plist', $args); 

    } 

} 

내가 flush_rewrite_rules()을 시도하고 작동하지 않았다 여기에

은 링크

/** 
* Add Price List archive template 
* @since 1.0.0 
*/ 
add_filter('archive_template', 'get_plist_archive_template') ; 
function get_plist_archive_template($archive_template) { 
    global $post; 

    if (is_post_type_archive ('plist')) { 
      $archive_template = dirname(__FILE__) . '\partials\archive-plist.php'; 
    } 
    return $archive_template; 
} 

아카이브 페이지 코드를입니다.

답변

1

가장 먼저 확인해야 할 것은 사용자 정의 게시물 유형이 코드에서 보관 기능을 사용하도록 설정되어 있어야한다는 것입니다. 이렇게하려면 사용자 정의 게시물 유형 코드 (테마의 functions.php 파일 또는 사이트 별 플러그인 파일에서 찾을 수 있음)로 이동해야합니다. has_archive 인수를 true로 설정해야합니다.

예제 코드는 다음과 같습니다

add_action('init', 'create_post_type'); 
function create_post_type() { 
    register_post_type('plist', 
     array(
      'labels' => array(
       'name' => __('plist'), 
       'singular_name' => __('plist') 
      ), 
     'public' => true, 
     'has_archive' => true, 
     ) 
    ); 
} 
+0

그것은 이미있다. 제 코드를 읽어주세요. – Yamona

관련 문제