How to delete Category in wordpress url ?

Tommy

Moderator
Joined
Sep 28, 2012
Messages
370
Points
43
Hi, anyone knows how to delete Category in wordpress url or change name into other?
example
https://www.webmastersun.com/category/domains-for-sale/
with
https://www.webmastersun.com/domains-for-sale/

Thanks
 

webdesign

New member
Joined
Jul 5, 2012
Messages
232
Points
0
Open functions.php in template folder
and add code

Code:
add_filter(‘user_trailingslashit’, ‘remcat_function’);
function remcat_function($link) {
return str_replace(“/category/”, “/”, $link);
}
add_action(‘init’, ‘remcat_flush_rules’);
function remcat_flush_rules() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
add_filter(‘generate_rewrite_rules’, ‘remcat_rewrite’);
function remcat_rewrite($wp_rewrite) {
$new_rules = array(‘(.+)/page/(.+)/?’ => ‘index.php?category_name=’.$wp_rewrite->preg_index(1).’&paged=’.$wp_rewrite->preg_index(2));
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
cheers,
 

jdunhin

New member
Joined
Feb 27, 2013
Messages
93
Points
0
You can also use Yoast SEO plugin for that. But thank you for the code it is also nice to know because you don't want use to much plugins on your site.
 

OWF

New member
Joined
Feb 25, 2013
Messages
69
Points
0
this is very easy to do, just goto your wordpress settings and go to the permalink section where you can select how your link will be presented.
 

linda0288

New member
Joined
Jul 29, 2013
Messages
14
Points
0
By default, WordPress category permalinks are displayed that way:

http://www.xxxxx.com/blog/category/wordpress As you can see, the category in the url is pretty useless. Here's how to remove it:

First backup your .htaccess file. Then, open it and append the following line:

RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]Once saved, your categories pages will be displayed like this:

http://www.xxxxx.com/blog/wordpress
 
Older threads
Replies
16
Views
6,843
Replies
16
Views
8,610
Replies
11
Views
6,279
Replies
4
Views
4,042
Newer threads
Replies
2
Views
4,855
Replies
6
Views
3,883
Replies
0
Views
3,227
Replies
28
Views
13,609
Replies
6
Views
4,500
Latest threads
Replies
1
Views
80
Replies
1
Views
175
Replies
4
Views
383
Replies
11
Views
525
Replies
2
Views
228
Recommended threads
Replies
22
Views
11,976
Replies
0
Views
2,749
Replies
9
Views
3,286
Replies
8
Views
2,515

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top