Custom Taxonomy rewrite rule causes 404 error on page or single post depending on if it’s set to “True” or “False”

Question

I’ve been googling, tinkering around and investigating/testing settings however nothing seems to work so please bear with me on this and please help me if you can. Thanks so much!

I have the custom taxonomy called “location” created via the CPT UI plugin and “Custom Structure” of example.com/%location%/%postname%/ in Settings >> Permalinks.

Below is the code used by CPT UI plugin to register new taxonomy “location”.

function cptui_register_my_taxes_location() {

    /**
     * Taxonomy: Locations.
     */

    $args = array(
        "public" => true,
        "publicly_queryable" => true,
        "hierarchical" => true,
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'location', 'with_front' => true, ),
        "show_admin_column" => true,
        "show_in_rest" => true,
        "rest_base" => "location",
        "rest_controller_class" => "WP_REST_Terms_Controller",
        "show_in_quick_edit" => true,
        );
    register_taxonomy( "location", array( "post", "blog" ), $args );
}
add_action( 'init', 'cptui_register_my_taxes_location' );

So my standard posts have this URL: sitename.com/”location”/”postname”

However when viewing my standard WP PAGES sitename.com/contact, sitename.com/about-us, and all other items under “pages”, it returns 404 error.

**Some investigation result:**When I change "rewrite" to False, issue is fixed on the standard page, however 404 error is encountered in the post e.g. sitename.com/”location”/”postname”. When "rewrite" is set back to True, single post is with no error however 404 is encountered in Page.

Has anyone encountered this issue before, or does anyone have any idea why this is happening?

Appreciate your help! Much thanks guys!

0
Bacorrito 4 months 0 Answers 12 views 0

Leave an answer