Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Wordpress use the page instead of category

Tags:

php

wordpress

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.)

like image 382
Arno Tenkink Avatar asked Aug 31 '15 11:08

Arno Tenkink


Video Answer


1 Answers

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

like image 57
limeygent Avatar answered Oct 25 '22 17:10

limeygent