Skip to content

Category rewrite rules are generated incorrectly with custom rewrite front if stripcategorybase is active #22132

Open
@ocean90

Description

@ocean90
  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

I noticed this issue with a multisite but this should affects any site which uses a permalink structure with a custom front like /blog/posts/%postname%/.

In my case the $blog_prefix was set to blog/ which means any access to /blog/posts/<category-name>/ lead to a 404 page.

Related code:

$permalink_structure = get_option( 'permalink_structure' );
$blog_prefix = '';
if ( strpos( $permalink_structure, '/blog/' ) === 0 ) {
if ( ( is_multisite() && ! is_subdomain_install() ) || is_main_site() || is_main_network() ) {
$blog_prefix = 'blog/';
}
}

Note that the /blog prefix is no longer required as of https://core.trac.wordpress.org/changeset/34749.

To Reproduce

Step-by-step reproduction instructions

  1. Create a multisite which is not a subdomain install
  2. Use /blog/posts/%postname%/ as the permalink structure for the main site
  3. Create a post with a category
  4. Try to access the category archive

Expected results

  1. /blog/posts/<category-name>/ returns the category archive

Actual results

  1. /blog/posts/<category-name>/ returns a 404 page

Screenshots, screen recording, code snippet

If possible, please provide a screenshot, a screen recording or a code snippet which demonstrates the bug.

Technical info

  • If relevant, which editor is affected (or editors):
  • Block Editor
  • Gutenberg Editor
  • Elementor Editor
  • Classic Editor
  • Other:
  • Which browser is affected (or browsers):
  • Chrome
  • Firefox
  • Safari
  • Other:

Used versions

  • Device you are using:
  • Operating system:
  • PHP version:
  • WordPress version:
  • WordPress Theme:
  • Yoast SEO version:
  • Gutenberg plugin version:
  • Elementor plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions