How to remove the /category/ from WP without plugin - php

my website blog is http://hawaiiturtletours.com/category/blog/. This is the only category on the site. I would like to know how can I remove or overwrite the URL for this page only so the new one is http://hawaiiturtletours.com/blog. One of the most suggested solutions in this case to overwrote URLs with the settings /%category%//%postname%/ does not work in my case.
Thanks!

From the WordPress Codex:
The Category base and Tag base are prefixes used in URLs for category
and tag archives, which look like this:
> example.net/wp/category_base/category_name
> example.net/wp/tag_base/tag_name
The default values for these are category and tag. You can change them, but > > you can't remove them from the URLs altogether.
A blog isn't really a category. If you go to WordPress Settings > Reading you'll see the option "Front Page Displays:". Change it to a 'static page' and select a page to be your static front page. You may need to create it at this point. Then you'll want to create a page called "blog" and back in Settings > Reading change "Posts Page:" to be your "blog" page.
This will give you the desired URL hawaiiturtletours.com/blog

Related

WordPress url change, only for some categories

I have several categories in my WordPress blog. All posts are available through domain.tld/post-title. But now I need different urls for certain topics.
Example:
Blog > domain.tld/post-title
Category 1 > domain.tld/category-1/post-title
Category 2 > domain.tld/category-2/post-title
Category 3 > domain.tld/post-title
I would prefer not to use a plugin and set everything via custom-template.php or functions.php. I have seen a few solutions with str_replace, but unfortunately none of them worked properly for me.
I also use different layouts for different categories. So I could also use something inside the template file to change the urls.
This should be available through Wordpress' default functionality by using categories for each post & updating the permalinks.
If you already have the categories in place under "Posts -> Categories"
and have assigned them to each post then your next step would be setting how it is displayed in your Permalinks tab.
Here you can set site-wide URL structure. In your case it would use
/%category%/%postname%/
which would put the category before the title of the post each time the URL is spun up by Wordpress.

Make Wordpress use the page instead of category

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.)
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.
WP Dashboard->Settings->Permalinks
Select "Custom Structure" and enter /%category%/%postname%/ in the field
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.
WP Dashboard->SEO->Advanced->Permalinks(tab)
"Change URLs->Strip the category base..." = Keep
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
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.
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.
Set permalink structure in settings to: /blog/%category/%postname%/ (/ trailing slash on the end is your preference)
Use SEO plugin like Yoast or Seopress Pro (or any other
method) to remove /category from URL.
Go to Settings -> Reading -> "Your homepage displays" section -> "A static page (select below)"
Set your static page for Homepage
Here is the magic: set Posts page to your "Blog" page.
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.

Exclude '/category/' from menu links URLs in WordPress

I work with wordpress site, where now category page is accessible from two types of links:
http://SITENAME.com/category/CATEGORY-NAME/
http://SITENAME.com/CATEGORY-NAME/
And from right-side menu the links shown as first type, which is wrong.
I need to setup side-menu links to looks like http://SITENAME.com/CATEGORY-NAME/ (without 'category' in every path).
How it can be done? I haven't found such settings neither in admin panel nor in templates...
I would recommend this plugin:
http://wordpress.org/plugins/wp-no-category-base/
The plugin requires no setup or modifying core wordpress files and will not break any links. It will also take care of redirecting your old category links to the new ones.
If you run a multilanguage site with WPML plugin, try this:
http://wordpress.org/plugins/no-category-base-wpml/

Give Wordpress custom page template a title for appearance editor

When in Wordpress theme appearance editor, certain pages have a neat titles displayed in the right hand list for your theme files.For example page.php shows as "Page Template". This is clean and easily read.
Is there any comment syntax that Wordpress uses to give these titles for my custom page template?
For example, my single-video.php page could be "Video Page Template".
Yes you can. Make sure your page opens with something like:
<?php /** Template Name: Text & Image
*/ get_header(); ?>
In this case the name of the file in your file overview (while in your appearance editor): Text & Image Page Template
I don't think so. The reason being that single-{type} pages are not essentially a required part of WordPress Template files, where as page.php is as it is used to for all static WordPress pages.
So it makes sense that WordPress people set a neat title for page.php and left single-{type} pages unattended. Also, type of single-{type} pages are user defined and subject to variation; where as page.php templates are not.
You may refer this page from WordPress Codex for more information
Yes, you need to provide a proper formatted URL (permalink) to wordpress Like either you want a dash (-) OR Forward Slash (/) OR whatever you want.
For this Go to Admin Panel > Appearance > Permalinks , here you can see the different styles of permalinks.You can create your own permalink structure too.
Find the attachment for your help.

In WordPress, how do I add a folder name in front of a slug?

I am using this theme: http://www.eleventhemes.com/gridly/
In order for the pages to only show certain posts on certain pages it requires the category folder in front of the slug so if I have a page called graphic-design it has to be accessed this way: domain.com/category/graphic-design. When I go to edit the page in WP it automatically removes the / after the word category.
How can I add a folder name in front of the page name?
That sounds like a bug in the theme. My first guess is that there's a naming collision. I believe "category" is the slug Wordpress uses for displaying post categories, while the theme is trying to use "category" to rewrite page permalinks.
As an experiment, try editing Wordpress' built-in Category base option.
Try going to Dashboard > Settings > Permalinks, and at the bottom under "Category base" set the field to something besides "category", like "mycats" or whatever. For fun try setting it to "category" explicitly and see what happens.

Categories