wordpress Один (общий) url (сегмент, slug) для типа записи и таксономии post type, taxonomy (CPT UI)
Primary tabs
Выясняем как это сделать
CPT UI и данная проблема
Распространенные в интернете решения (в т.ч. те, тчо по ссылкам ниже) не работали, так как CPT UI судя по всему регистрирует таксономию до типа записи, поэтому в качестве решение подошло изменение:
add_action( 'init', 'cptui_create_custom_post_types', 10); // Leave on standard init for legacy purposes.
на
add_action( 'init', 'cptui_create_custom_post_types', 7); // Leave on standard init for legacy purposes.
в файле wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php, контекст:
/** * Register our users' custom post types. * * @since 0.5.0 * * @internal */ function cptui_create_custom_post_types() { $cpts = get_option( 'cptui_post_types' ); if ( empty( $cpts ) ) { return; } /** * Fires before the start of the post type registrations. * * @since 1.3.0 * * @param array $cpts Array of post types to register. */ do_action( 'cptui_pre_register_post_types', $cpts ); if ( is_array( $cpts ) ) { foreach ( $cpts as $post_type ) { cptui_register_single_post_type( $post_type ); } } /** * Fires after the completion of the post type registrations. * * @since 1.3.0 * * @param array $cpts Array of post types registered. */ do_action( 'cptui_post_register_post_types', $cpts ); } add_action( 'init', 'cptui_create_custom_post_types', 10 ); // Leave on standard init for legacy purposes.
Что почитать:
- Похожее решение в коде: https://wp-kama.ru/question/izmenenie-ya...
- Custom WordPress Rewrite Rule to Combine Taxonomy and Post Type: https://www.ibenic.com/custom-wordpress-...
- Log in to post comments
- 1956 reads