skip to Main Content

I did a great amount of research and came across some solutions like this:
https://wordpress.stackexchange.com/questions/106042/force-wordpress-to-show-pages-instead-of-category

But still it isn’t exactly what I’m looking for. First of all let me explain the problem.

I made a page /blog/ and a category ‘blog’ both make use of the permalink /blog/, disabled the /category/ permalink so the SEO will be correct.

The solutions I came across didn’t match the following requirements:

  • Not using 301 redirects
  • Disable the /category/ use within WordPress.
  • Also make it possible to only replace category when a page id uses the same slug.

I simply like to tell WordPress to display the page instead of the category.

Why don’t you just edit the category template?

Because the page I created uses Visual Composer (Post Masonry Grid) so I can’t simple move the design.

Why don’t you just use redirects?

I would like to but the permalink of the blog is the same as the page (SEO purpose.)

2

Answers


  1. I know it’s a few years later with no solution, but I had the exact same problem you described on one site that was working in other sites. So I did some research on what was different and to help others should they run into the same issue.

    Background

    • example.com is the domain

    • I have a WP page called “foobar” with content

    • I have a WP post category called “foobar”

    • I have a WP post entitled “fun things to do with foobars”, and the category is set to “foobar”

    Expectations

    • When I go to example.com/foobar, I want to see the page about foobars, not a WP category page that shows all blog posts with that category.

    • When I go to the blog post about fun things, the URL is example.com/foobar/fun-things-to-do-with-foobars/

    Setup

    Here’s my setup (it does not require any additional plugins or code edits)
    A couple of installed plugins are WP Rocket and Yoast on which I’ll focus in this thread.

    1. WP Dashboard->Settings->Permalinks

    2. Select “Custom Structure” and enter /%category%/%postname%/ in the field

    3. On the same page, change “Category base” to a single dot. “.” (no quotes, just a single dot/period/full stop

    I have Yoast installed, which I had set up to override the permalink settings, but I believe this messed up my task at hand.

    1. WP Dashboard->SEO->Advanced->Permalinks(tab)

    2. “Change URLs->Strip the category base…” = Keep

    3. Then you need to clear the cache. I use WP Rocket for caching, so I flushed the cache and everything now works the way it should.

    Edit: make sure you save your changes after steps 3 and 5

    Login or Signup to reply.
  2. I know this topic is old but question is still important.

    I will use blog example.
    This method is code free, WP native solution. One caveat is that you cannot translate "blog" slug, so this method is only for one language if you don’t need to have different words/slugs for other languages.

    1. Create page with slug "blog". Or whatever you like. It must match word you put in next step as base: blog = blog it this example.
    2. Set permalink structure in settings to: /blog/%category/%postname%/ (/ trailing slash on the end is your preference)
    3. Use SEO plugin like Yoast or Seopress Pro (or any other
      method) to remove /category from URL.
    4. Go to Settings -> Reading -> "Your homepage displays" section -> "A static page (select below)"
    5. Set your static page for Homepage
    6. Here is the magic: set Posts page to your "Blog" page.
    7. Flush permalinks by visiting and saving settings on Permalink page (without any change).

    Then you will get proper URL: /blog/yourcategory/single-post-title/
    Breadcrumbs will work, all categories will be hierarchical, and /blog will work as page instead of category.

    Most importantly, when you go to your category page you will get /blog/yourcategory URL and it will work as archive page. When you visit single post, then also you get URL /blog/yourcategory/single-post-title/

    Breadcrumbs from Yoast should work. I use Seopress Pro and breadcrumbs works like a charm (you have to go to breadcrumbs setting page and select categories for posts and posts for categories and tags if you need them).

    If you do it without including /blog in your permalink setting it will still work, you will get page instead of category with proper url for categories, but single post will be /yourcategory/single-post-title.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search