При помощи плагина Types создали каталог (product/%category%/%postname%/)
После чего product теперь оказался не нужным и product выпилили, "обычным" способом
function gp_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( 'product' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'gp_remove_cpt_slug', 10, 3 );
function gp_parse_request_trick( $query ) {
if ( ! $query->is_main_query() )
return;
if ( 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
return;
}
if ( ! empty( $query->query['name'] ) ) {
$query->set( 'post_type', array( 'post', 'page', 'product' ) );
}
}
add_action( 'pre_get_posts', 'gp_parse_request_trick' );
но ситуация немного "необычная" есть /%category%/ .
Все нормально при переходе на /%category%/, но на /%category%/%postname%/ вылезает 404 ошибка.
Как это исправить?