我正在尝试创建分类页面,因此我使用分类法taxonomy-nowe.php 创建了分类法
但我的 WP 看不到该页面,或者我弄乱了重写 URL?有人可以检查我的代码并看看我是否做错了什么。我通过保存平原来刷新永久链接,然后返回到帖子名称永久链接。但我没有得到结果。
我想实现这样的目标:domain.pl/oferta/kopiarki/nowe
// custom post type
function td_devices_posttype() {
$labels = array(
'name' => _x( 'Kopiarki', 'Ogólna nazwa wpisów', 'textdomain' ),
'singular_name' => _x( 'Kopiarka', 'Pojedyńcza nazwa wpisu', 'textdomain' ),
'menu_name' => esc_html__( 'Kopiarki', 'textdomain' ),
'parent_item_colon' => esc_html__( 'Rodzic', 'textdomain' ),
'all_items' => esc_html__( 'Wszystkie kopiarki', 'textdomain' ),
'view_item' => esc_html__( 'Wyświetl kopiarki', 'textdomain' ),
'add_new_item' => esc_html__( 'Dodaj nową kopiarkę', 'textdomain' ),
'add_new' => esc_html__( 'Dodaj nową', 'textdomain' ),
'edit_item' => esc_html__( 'Edytuj Kopiarkę', 'textdomain' ),
'update_item' => esc_html__( 'Zaktualizuj kopiarkę', 'textdomain' ),
'search_items' => esc_html__( 'Szukaj kopiarkę', 'textdomain' ),
'not_found' => esc_html__( 'Nie zanleziono', 'textdomain' ),
'not_found_in_trash' => esc_html__( 'Nie znaleziono w koszu', 'textdomain' )
);
$args = array(
'label' => esc_html__( 'kopiarki', 'textdomain' ),
'description' => esc_html__( 'Wszystkie kopiarki', 'textdomain' ),
'labels' => $labels,
'taxonomies' => array( 'nowe' ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 100,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'query_var' => true,
'show_admin_column' => true,
'capability_type' => 'page',
'rewrite' => array('slug' => 'oferta/kopiarki'),
'supports' => array( 'title','editor','thumbnail', 'custom-fields')
);
register_post_type( 'kopiarki', $args );
//flush_rewrite_rules();
}
add_action( 'init', 'td_devices_posttype' );
// custom taxonomies new
function new_posttype_taxonomy() {
$labels = array(
'name' => 'Nowe',
'singular_name' => 'Nowa',
'search_items' => 'Szukaj nowych',
'all_items' => 'Wszystkie nowe kopiarki',
'parent_item' => 'Rodzic',
'parent_item_colon' => 'Dwukropek elementu nadrzędnego:',
'edit_item' => 'Edytuj nową kopiarkę',
'update_item' => 'Zaktualizuj nową kopiarkę',
'add_new_item' => 'Dodaj nową kopiarkę',
'new_item_name' => 'Nowa nazwa kopiarki',
'menu_name' => 'Nowe'
);
$args = array (
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'show_in_rest' => true,
'query_var' => true,
'rewrite' => array(
'slug' => 'nowe',
'with_front' => false,
)
);
register_taxonomy( 'nowe', array( 'kopiarki' ), $args );