태그 보관물: custom-post-types

custom-post-types

맞춤 게시물 유형 보관 페이지가 표시되지 않음 = true;내 포함functions.php 동일한 웹 사이트에서

내 웹 사이트에 ‘프로필’이라는 카테고리가 있습니다.이 카테고리를 ‘프로필’이라는 맞춤 게시물 유형으로 이동하는 중입니다.

내 문제는이 맞춤 게시물 유형에 대해 보관 페이지를 표시 할 수 없다는 것입니다. URL로 이동 mywebsite.com/profiles하면 프로필 카테고리의 게시물에 대한 단일 게시물 페이지로 이동합니다.

나는 has_archive = true;내 포함functions.php

동일한 웹 사이트에서 수행 한 다른 사용자 지정 게시물 유형에 대한 보관 페이지를 만드는 데 문제가 없었으므로 이번에는 왜 이것이 작동하지 않는지 실감했습니다.

어떤 조언을 가장 감사하겠습니다?

add_action( 'init', 'profile_custom_init' );

/* Here's how to create your customized labels */
function profile_custom_init() {
$labels = array(
    'name' => _x( 'Profiles', 'post type general name' ), // Tip: _x('') is used for localization
    'singular_name' => _x( 'Profile', 'post type singular name' ),
    'add_new' => _x( 'Add New', 'Profile' ),
    'add_new_item' => __( 'Add Profile' ),
    'edit_item' => __( 'Edit Profile' ),
    'new_item' => __( 'New Profile' ),
    'view_item' => __( 'View Profile' ),
    'search_items' => __( 'Search Profile' ),
    'not_found' =>  __( 'No Profile found' ),
    'not_found_in_trash' => __( 'No Profile found in Trash' ),
    'parent_item_colon' => ''
);

// Create an array for the $args
$args = array( 'labels' => $labels, /* NOTICE: the $labels variable is used here... */
    'public' => true,
    'publicly_queryable' => true,
    'has_archive' => true,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => 10,
    'supports' => array( 'title', 'editor','thumbnail', 'excerpt', 'custom-fields' ),
        'taxonomies' => array('category')
    );

    register_post_type( 'profile', $args ); /* Register it and move on */
}



답변

  1. 설정-> 퍼머 링크로 이동
  2. 영구 링크 구조를 기본값으로 변경
  3. 설정 저장
  4. 사용자 정의 구조 또는 게시물 이름 (또는 다른 구조)으로 변경
  5. 설정 저장

htaccess 파일을 다시 쓴 다음 다시 쓸 수 있습니다.


위의 솔루션이 작동하지 않으면 서버 구성과 관련이 있어야합니다.

Aapache2

운영: a2enmod rewrite && service apache2 reload

니 진스

따르십시오 : https://do.co/2LjCF8r


시간이 절약 되길 바랍니다.


답변

퍼머 링크 구조를 다시 저장하면 문제가 해결 된 것 같습니다. 팁 Mike와 Vinod에 감사드립니다.


답변