Same base for category and post

I'd like to have the following:

Single Post test.com/blog/new-category/post-name/

Category test.com/blog/new-category/

So I changed the Permalink structure to: /blog/%category%/%postname%/ and the category base to blog. But this gives me a 404 on the post.

So I tried blog/. for the category base, which works. But only for the first page. On the second page it gives me a 404 for test.com/blog/new-category/page/2/.

I guess WP is looking for a post with the slug page/2/.

Does anybody had a similar problem and may know a solution?

Thanks!

Topic permalinks categories 404-error Wordpress

Category Web


  • Change Category base to . (dot). Nobody knows this trick will work in the future, but there is no easy way to remove /category/ from the URL. So, it's better to google for a plugin (here is one of them). Yoast's SEO plugin also is able do the same.

  • Set Permalink structure to /blog/%category%/%postname%/.

Then:

the_posts_pagination();

This function does not require any arguments in your case.

If you really want to use paginate_links(), use the right format argument value because pretty permalinks were already set: page/%#%/ rather than ?paged=%#%:

echo paginate_links( array('format' => 'page/%#%/') );

See Pagination functions for more.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.