• I’m want to redirect every category page to to URL prepended by /category.
    For example; I want /blog redirecting to /category/blog

    Why? For some reason /blog gives to same result as /category/blog, but if you’ll visit /blog the navigation structure doesn’t work anymore. The next page of blogs posts will be /blog/page/2 instead of /category/blog/page/2. The first example returns an 404 page.

    My permalink structure is set to /%category%/%postname%/ and on the permalink page I’ve set the categorybase to ‘categorie’, Dutch for category (so read every category above as categorie haha).

    Somewhere on the internet I did found the following piece of code. Unfortunately this code leads to a redirect loop:

    add_filter('term_link', 'term_link_filter', 10, 3);
    function term_link_filter( $url, $term, $taxonomy ) {
        if ( is_category( 'blog' ) ) {
    	$url = site_url( '/categorie/blog' );
    	wp_safe_redirect( $url, 301 );
            exit;
        }
    
        return $url;
    }

    Hopefully someone will know a solution.

  • The topic ‘Redirect category to url with /category’ is closed to new replies.