1
내가 가지고있는 다음과 같은 사용자 정의 포스트 타입과 사용자 정의 분류 설정 :URL에 분류법 슬러그를 포함 시키시겠습니까?
add_action('init', 'create_post_type');
function create_post_type() {
register_post_type('system',
array(
'labels' => array(
'name' => __('Systems'),
'singular_name' => __('System')
),
'capability_type' => 'post',
'supports' => array('title','editor','comments'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'system'),
)
);
}
function news_init() {
register_taxonomy(
'system',
'system',
array(
'label' => __('Product Category'),
'sort' => true,
'hierarchical' => true,
'args' => array('orderby' => 'term_order'),
'rewrite' => array('slug' => 'products')
)
);
}
add_action('init', 'news_init');
는 URL에서 사용자 정의 분류 이름을 포함 할 수 있습니까?
나는 사용자가 URL을 게시 GOTO 때 현재는 다음과 같습니다
가 어떻게 그것을 다음과 같이 만들 수 있습니까?
http://www.domain.com/(category-slug)/(post-name)/
는 그 URL로 이동 시도했지만 그것은 단지 404 난 그냥 표준 아카이브 템플릿 설정을 가지고 있습니다.(! 거기에 많은 활동이없는 것처럼 워드 프레스 스택에 내 질문을 마이그레이션하지 마십시오)
업데이트 : 한 페이지에 아래의 코드를 넣어
바로 확인이 오른쪽 페이지에가는 만들려면 그것은이 것 :이렇게하면 404가됩니다. 템플릿 (기본 파일)을 선택하지 않은 것 같아요. archive-products.php도 추가하려고했습니다.
<?php $args = array('taxonomy' => 'my_term'); $terms = get_terms('system', $args); $count = count($terms); $i=0; if ($count > 0) { $term_list = '<p class="my_term-archive">'; foreach ($terms as $term) { $i++; $term_list .= '<a href="' . get_term_link($term->slug, $term->taxonomy) . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $term->name . '</a>'; if ($count != $i) $term_list .= ' · '; else $term_list .= '</p>'; } echo $term_list; } ?>
내 질문을 업데이트했습니다. 나는 그 링크를 가로 질러 왔지만 여전히 운이 없었습니다. 네, 분류학 법안은 유감입니다. – Rob
안녕하세요, 어떻게 지내세요? – SMacFadyen
2 일 동안 사용했습니다! 다시 확인해 주셔서 감사하지만 운이 아직 없습니다. – Rob