Multisite (subdirectory installation) CPT single page bug
-
Site with bug:
http://dev.pilot-telematics.com/es/blog-resources/
It will be move soon to the main domain http://pilot-telematics.com/es/blog-resources/My setup:
- Multisite with subdirectory installation (en – base, es, pt).
- CPT + CT (post_blog, blog_cat), which assign with blog-resources page.
- WP better permalinks: post_blog assign with blog_cat.
Bug:
Example link:/blog-resources/blog/new-in-release-7-6/<– Ok/es/blog-resources/blog/presentamos-pilot-7-6-actualizado/<– 404I’ve tried to make same URL (new-in-release-7-6) same result.
Taxonomies page works correct at all sites (en, es, pt).
Main issue at single page of CPT on es, pt subfolders.Temporary i’ve made patch, which solve the issue. Code bellow:
add_filter( "request", "resolve_same_slug_conflict" );
function resolve_same_slug_conflict( $query_vars ) {
// Array with my CT and CPT
$custom_taxonomies = array(
"product_cat" => "post_product",
"solution_cat" => "post_solution",
"blog_cat" => "post_blog",
"partner_client_cat" => "post_partner_client"
);
$slug_to_check = "";
$current_taxonomy = "";
$current_post_type = "";
foreach ( $custom_taxonomies as $taxonomy => $post_type ) {
if ( isset( $query_vars[$taxonomy] ) ) {
$slug_to_check = basename( untrailingslashit( $query_vars[$taxonomy] ) );
$current_taxonomy = $taxonomy;
$current_post_type = $post_type;
}
}
if( empty( $slug_to_check ) ) {
return $query_vars;
}
$post_exists = get_page_by_path( $slug_to_check, OBJECT, $current_post_type );
if ( $post_exists ) {
unset( $query_vars[$current_taxonomy] );
$query_vars['post_type'] = $post_exists->post_type;
$query_vars['name'] = $slug_to_check;
}
return $query_vars;
}Also I tried this solution, but it was another bug, which duplicate base page URL (blog-resources), when i call the_permalink()
/es/blog-resources/blog-resources/blog/presentamos-pilot-7-6-actualizado/<– URL in loop with the_permalink() – 404/es/blog-resources/blog/presentamos-pilot-7-6-actualizado/<– correct URL, which work – 200add_action( "wbp_rewrites", function ( $value ) {
foreach ( $value as &$item ) {
$regexLang = preg_replace( '/^(?:(?:[a-z]{2}\/)?)(.*)/', '${1}', $item['regex'] );
$item['regex'] = $regexLang;
}
return $value;
} );Rollback to the version of 3.0.9 does not solve the issue.
I would really like to see a solution to this problem in future plugin updates.
Perhaps there’s a better solution at this point.
I’m eagerly awaiting a response from the developer!Thank you!
The page I need help with: [log in to see the link]
You must be logged in to reply to this topic.