Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to change sub url WordPress

  • REFUNDED

Hello I have the CUSTOM CATEGORY 'portfolio' which shows up as mywebsite.com/portfolio-view/

How do I REMOVE "portfolio-view" from the url?

Answers (7)

2012-09-02

Clifford P answers:

Go to your category settings. Click to edit this category. Change the category's slug to something else.

2012-09-02

Asad Iqbal answers:

Change your category slug.

2012-09-02

Jatin Soni answers:

You need to change your custom texonomy slug. For that open the file where you have registers your custom post type. May be in functions.php file

and find something like <strong>register_taxonomy</strong> in that find <strong>'slug' =></strong> add your slug here

'slug' => 'portfolio-view'

If you haven't define rewrite rule than you can define with similar code below

register_taxonomy(
'portfolio_category', // The name of the custom taxonomy
array( 'portfolio' ), // Associate it with your custom post type
array(
'hierarchical' => true,
'rewrite' => array(
'slug' => 'portfolio-view', // this is for your permalink what you asked
'hierarchical' => true // Allows sub-categories to appear in permalinks
),
'labels' => $labels_categories
)

);



liv comments:

Will this completely remove the slug?


Jatin Soni comments:

It won't remove but define the slug what you want. You need to implement this code where you have register your Portfolio Custom Post Type. If you have any problem than send me the Portfolio CPT register code than I will modify and post it.


liv comments:

I need to completely remove the slug because the url is going to be used for vanity urls


Jatin Soni comments:

You may get solution here than..

http://wordpress.stackexchange.com/questions/42120/remove-slug-in-taxonomy-url
http://wordpress.stackexchange.com/questions/12884/remove-slug-from-custom-post-type-url


liv comments:

I am trying the second suggestion to change it to:
add_rewrite_rule('(the-post-slug)/?$','index.php?<post type>=$matches[1]','top');

So I assume I should change it to:
add_rewrite_rule('(portfolio-view)/?$','index.php?<post type>=$matches[1]','top');

And put that in the functions.php
And then go into permalinks.

But that does not work.

2012-09-02

Abdelhadi Touil answers:

Hi. Do you mean that you want to remove the category and its slug from your website? or just the slug? If you want to remove just the slug so why keeping the category?
I just want to understand to be able to help you.

2012-09-02

Francisco Javier Carazo Gil answers:

Hi liv,

Remember to change portfolio-view also in second argument:
add_rewrite_rule('(portfolio-view)/?$','index.php?portfolio-view=$matches[1]','top');

Later you have to go to this file, only introduce URL (you have to logged-in before), and job will be done:
<em>your-site.com/wp-admin/options-permalinks.php</em>


liv comments:

Did this exactly, still does not remove the portfolio-view. Do I need to do it under another file? I also tried using this code for the "theme-function.php" and it did not work either. Are you sure:

add_rewrite_rule('(portfolio-view)/?$','index.php?portfolio-view=$matches[1]','top');

Is the correct code?

I also tried:
add_rewrite_rule('(portfolio-view)/?$','index.php?<portfolio-view>=$matches[1]','top');
add_rewrite_rule('(portfolio-view)/?$','index.php?portfolio-view=$matches[1]','top');
add_rewrite_rule('(portfolio-view)/?$','index.php?<post type>=$matches[1]','top');

And then visiting the permalinks, none of these code lines worked.

2012-09-02

idavinder answers:

What I understand, you want to display category 'portfolio' as mywebsite.com/portfolio/

which is currently showing as mywebsite.com/portfolio-view/


Here goes...

1. Login into your Wordpress dashboard. Then goto Pages > Categories
2. Click "Edit" button under Portfolio view category listing there.
3. In the Slug text box (2nd from top) change portfolio-view to Portfolio

See the attached screenshot, remove the selected part of the text.


liv comments:

sigh

2012-09-04

Daniel answers:

Whenever you make these changes to the rules of the Custom Taxonomy, Category or Custom Post Types; anything that changes the link, you need to also go to your WordPress settings and click on Update Permalinks for the code changes to show in the link.


Daniel comments:

This tutorial from StackExchange might help you.

http://wordpress.stackexchange.com/questions/9419/remove-taxonomy-slug-from-a-custom-hierarchical-taxonomy-permalink


Daniel comments:

This might help: http://wpjourno.com/custom-post-types-custom-taxonomy/