1

나는 forms_cpt이라는 CPT와 forms_tax이라는 분류를 가지고 있습니다. 내 page-forms.php에서 나는 용어 ​​목록을 만드는분류학 기간 퍼머 링크가 작동하지 않습니다.

<ul> 
<?php 
foreach ($tax_terms as $tax_term) { 
echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf(__("View all posts in %s"), $tax_term->name) . '" ' . '>' . $tax_term->name.'</a></li>'; 
} 
?> 
</ul> 

같은 forms_tax 용어 목록 상자에 수 있어요. 하지만 클릭 할 때마다 URL이 잘못되었습니다. 예를 들어 당신이 나에게 이런 일이 내가 무슨 일을하고있는 이유 알려 주시기 바랍니다 수 있습니다

http://www.domain.ca/soccer/ 

대신

http://www.domain.ca/Forms/soccer/ 

에 도착 soccer 용어를 클릭하면 ? 기능 gen_forms_tax() {

$labels = array(
     'name'      => 'Form Types', 
     'singular_name'    => 'Form Type', 
     'menu_name'     => 'Form Types', 
     'all_items'     => 'All Form Types', 
     'parent_item'    => 'Form Parent', 
     'parent_item_colon'   => 'Form Parents:', 
     'new_item_name'    => 'New Form Name', 
     'add_new_item'    => 'Add New Form', 
     'edit_item'     => 'Edit Form', 
     'update_item'    => 'Update Form', 
     'separate_items_with_commas' => 'Separate Form with commas', 
     'search_items'    => 'Search Form', 
     'add_or_remove_items'  => 'Add or remove Form', 
     'choose_from_most_used'  => 'Choose from the most used Form', 
     'not_found'     => 'Form Not Found', 
    ); 
    $args = array(
     'labels'      => $labels, 
     'hierarchical'    => true, 
     'public'      => true, 
     'show_ui'     => true, 
     'show_admin_column'   => true, 
     'show_in_nav_menus'   => true, 
     'show_tagcloud'    => true, 
    ); 
    register_taxonomy('forms_tax', array('forms_cpt'), $args); 

} 

add_action('init', 'gen_forms_tax', 0); 



function gen_forms_cpt() { 

    $labels = array(
     'name'    => 'Forms', 
     'singular_name'  => 'Form', 
     'menu_name'   => 'Form', 
     'name_admin_bar'  => 'Form', 
     'parent_item_colon' => 'Form Parent:', 
     'all_items'   => 'All Forms', 
     'view_item'   => 'View Forms', 
     'add_new_item'  => 'Add New Form', 
     'add_new'    => 'Add New Form', 
     'new_item'   => 'New Form', 
     'edit_item'   => 'Edit Form', 
     'update_item'   => 'Update Form', 
     'search_items'  => 'Search Form', 
     'not_found'   => 'Form Not found', 
     'not_found_in_trash' => 'Form Not found in Trash', 
    ); 
    $args = array(
     'description'   => 'This Post Type Adds Form to Website', 
     'labels'    => $labels, 
     'supports'   => array('title', 'excerpt',), 
     'taxonomies'   => array('forms_tax'), 
     'hierarchical'  => true, 
     'public'    => true, 
     'show_ui'    => true, 
     'show_in_menu'  => true, 
     'show_in_nav_menus' => true, 
     'show_in_admin_bar' => true, 
     'menu_position'  => 5, 
     'rewrite'    => array('slug' => 'Forms','with_front' => true, 'hierarchical' => true), 
     'can_export'   => true, 
     'has_archive'   => true, 
     'exclude_from_search' => false, 
     'publicly_queryable' => true, 
     'capability_type'  => 'post', 
    ); 
    register_post_type('forms_cpt', $args); 

} 

add_action('init', 'gen_forms_cpt', 0); 

답변

1

해결 방법 : 아래의 단계를 수행해야합니다.

1) Go to Settings from Admin panel. 
2) Go to permalinks 
3) Save the permalinks 

parmalinks를 저장 한 후에 작동해야합니다. 다시 쓰기 규칙을 사이트에 추가하면 항상 퍼머 링크를 업데이트해야합니다.