admin管理员组

文章数量:1122832

The problem is complex. When ACF and YAST SEO are activated, and custom taxonomy does not have a slug, the code is below. However, regular pages display a 404 error. I tested it on pure WordPress. ACF purchased, latest version.

register_taxonomy(
'course_cats',
'course',
 array(
 'hierarchical'      => true,
 'show_admin_column' => true,
 'show_in_nav_menus' => true,
 'labels'            =>array(),
 'query_var'         => true,
 'rewrite' => array( 'slug' => '/', 'with_front' => false),
 'show_in_rest' => true,
    )
  );

The problem is complex. When ACF and YAST SEO are activated, and custom taxonomy does not have a slug, the code is below. However, regular pages display a 404 error. I tested it on pure WordPress. ACF purchased, latest version.

register_taxonomy(
'course_cats',
'course',
 array(
 'hierarchical'      => true,
 'show_admin_column' => true,
 'show_in_nav_menus' => true,
 'labels'            =>array(),
 'query_var'         => true,
 'rewrite' => array( 'slug' => '/', 'with_front' => false),
 'show_in_rest' => true,
    )
  );
Share Improve this question edited Jun 1, 2024 at 17:54 Сергей Константинов asked Jun 1, 2024 at 17:53 Сергей КонстантиновСергей Константинов 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The problem is your slug parameter, it can't just be / - you need to have something that identifies the URL as being this taxonomy. It defaults to the taxonomy key which in this case would be course_cat but in the interest of human-readable URLS you could do this instead:

'rewrite' => array( 'slug' => 'course-category', 'with_front' => false )

本文标签: url rewritingHow to customize the url structure