Registered a custom type:

add_action( 'init', 'exercises' ); function exercises() { $labels = array( 'name' => 'УпраТнСния', 'singular_name' => 'Π£ΠΏΡ€Π°ΠΆΠ½Π΅Π½ΠΈΠ΅', 'add_new' => 'Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ ΡƒΠΏΡ€Π°ΠΆΠ½Π΅Π½ΠΈΠ΅', 'add_new_item' => 'Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π½ΠΎΠ²ΠΎΠ΅ ΡƒΠΏΡ€Π°ΠΆΠ½Π΅Π½ΠΈΠ΅', 'edit_item' => 'Π Π΅Π΄Π°ΠΊΡ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ ΡƒΠΏΡ€Π°ΠΆΠ½Π΅Π½ΠΈΠ΅', 'new_item' => 'НовоС ΡƒΠΏΡ€Π°ΠΆΠ½Π΅Π½ΠΈΠ΅', 'all_items' => 'ВсС упраТнСния', 'view_item' => 'ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΡŒ ΡƒΠΏΡ€Π°ΠΆΠ½Π΅Π½ΠΈΠ΅', 'search_items' => 'Π˜ΡΠΊΠ°Ρ‚ΡŒ ΡƒΠΏΡ€Π°ΠΆΠ½Π΅Π½ΠΈΠ΅', 'not_found' => 'Π£ΠΏΡ€Π°ΠΆΠ΅Π½Π΅Π½ΠΈΠ΅ Π½Π΅ Π½Π°ΠΉΠ΄Π΅Π½ΠΎ.', 'not_found_in_trash' => 'Π’ ΠΊΠΎΡ€Π·ΠΈΠ½Π΅ Π½Π΅Ρ‚ ΡƒΠΏΡ€Π°ΠΆΠ½Π΅Π½ΠΈΠΉ.', 'menu_name' => 'УпраТнСния' ); $args = array( 'labels' => $labels, 'public' => true, 'show_ui' => true, 'has_archive' => true, 'menu_icon' => 'dashicons-admin-page', 'menu_position' => 4, 'supports' => array( 'title', 'editor', 'comments'), 'taxonomies' => array( ), 'hierarchical' => true, ); register_post_type('exercises', $args); } 

Also registered taxonomy for categories:

 add_action( 'init', 'add_category_exercises'); function add_category_exercises() { $labels = array( 'name' => 'Π ΡƒΠ±Ρ€ΠΈΠΊΠΈ', 'singular_name' => 'Π ΡƒΠ±Ρ€ΠΈΠΊΠ°', 'all_items' => 'ВсС Ρ€ΡƒΠ±Ρ€ΠΈΠΊΠΈ', 'edit_item' => 'Π˜Π·ΠΌΠ΅Π½ΠΈΡ‚ΡŒ Ρ€ΡƒΠ±Ρ€ΠΈΠΊΡƒ', 'update_item' => 'Π˜Π·ΠΌΠ΅Π½ΠΈΡ‚ΡŒ Ρ€ΡƒΠ±Ρ€ΠΈΠΊΡƒ', 'add_new_item' => 'Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π½ΠΎΠ²ΡƒΡŽ Ρ€ΡƒΠ±Ρ€ΠΈΠΊΡƒ', 'new_item_name' => 'Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π½ΠΎΠ²ΡƒΡŽ Ρ€ΡƒΠ±Ρ€ΠΈΠΊΡƒ', 'menu_name' => 'Π ΡƒΠ±Ρ€ΠΈΠΊΠΈ' ); register_taxonomy('cat_exercises', array('exercises'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'exercises/muscle', 'with_front' => false, 'hierarchical' => true ) )); } 

So advised to do on the English stackoverflow. If arbitrary type of records work, then if you go to the taxonomy page returns 404 error.

That is, in theory should get such links:

site.com/exercises/example-post - the post link works, everything is fine.

site.com/exercises/muscle/press - link does not work, returns 404 error.

Question: why does not work and returns 404 error?

PS Update links made.

PS For @SeVlad Here is also an example of such an implementation: enter image description here

  • And what is the question? - SeVlad 5:59 pm
  • @SeVlad is what returns 404 error, and why it returns and does not work. - Alexander Semikashev
  • What is the address 404? - SeVlad
  • @SeVlad site.com/exercises/muscle/category - Alexander Semikashev
  • Write a question - SeVlad

1 answer 1

I doubt that so advise on SO

'slug' => 'exercises/muscle'

and naming existing terms ("rubrics")

Slug can not be with a slash.

Question: why does not work and returns 404 error?

So all is true - category - this is the slug of the native TPS taxonomy. What it does at site.com/exercises/muscle/category .

In general, the code is not correct, and the Wishlist to have the Slug taxonomy is not clear where.

And yes. In VP the same slugs cannot be. (Rather, they can, but they are very specific and do not need to bet on it)

Hardware: https://codex.wordpress.org/Function_Reference/register_post_type

https://codex.wordpress.org/Function_Reference/register_taxonomy

Help generator: https://generatewp.com

  • Just the same decision I found in one of the responses to SO. At the same time, I did everything. They advised to register the taxonomy before the registration of an arbitrary type. Then the links work as they should. - Alexander Semikashev
  • @AlexanderSemikashev Where did you find such a slug? - SeVlad
  • @AlexanderSemikashev and where is there such a heresy? 'slug' => 'exercises/muscle' - SeVlad
  • And if you need to associate your custom directory with a custom type, then you need to write it in the code (functions). But you did not indicate this in the question. - SeVlad