3

Remove the taxonomy base of the URL in WordPress

 2 years ago
source link: https://www.codesd.com/item/remove-the-taxonomy-base-of-the-url-in-wordpress.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Remove the taxonomy base of the URL in WordPress

advertisements

I have a little problem with removing the taxonomy base from the URL in Wordpress. I tried different approaches but none worked.

register_taxonomy('project_category','projects',array(
  'labels' => $labels,
  'show_ui' => true,
  'rewrite' => array(
      'slug' => 'project-category',
      'with_front' => false,
      'hierarchical' => true),
  'hierarchical' => true)
);

I currently see the URL like this : http://mysite.com/project-category/project1 and i want it to be like this: http://mysite.com/project1.

I tried to rewrite the slug to '' instead 'project-category' but that messed with all my othr pages, redirecting to a 404 page.


Heres how I've manage to get my url to rewirte to a spcific url.

add_action('init', 'portfolio_register');  

function portfolio_register() {
$args = array(
    'label' => __('Portfolio'),
    'singular_label' => __('Project'),
    'public' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => true,
    'supports' => array('title', 'editor', 'thumbnail')
   );  

register_post_type( 'portfolio' , $args );
}  

register_taxonomy(
   "project-type",
   array("portfolio"),
   array("hierarchical" => true,
   "label" => "Project Types",
   "singular_label" => "Project Type",
   "rewrite" => true
));

Also check out some tutorials and sometimes you can grab bits& pieces from theme.

Related Articles

PHP Remove the URL from the string

If I have a string that contains a url (for examples sake, we'll call it $url) such as; $url = "Here is a funny site http://www.tunyurl.com/34934"; How do i remove the URL from the string? Difficulty is, urls might also show up without the http:

Javascript alert indicating the URL of the site. How do I remove the URL from the site at the top of the javascript alert?

javascript alert box showing url + msg. i have not passed any thing but it shows url on the top of alert box. how can i remove this url ? The url is showing when my site is redirected from another site. Means redirect from abc.com to xyz.com and aler

.htaccess: redirect the URL from the root to the subdirectory, but remove the URL from the root

I am in the process of cleaning up my domain's directory structure (woe be to me for setting up the root url's content in the root directory!) and need some insight on how to use RewriteRule correctly. The Gist I want domain.tld to use domain.tld/sub

.html Removing the URL Using the .htaccess Rewrite Rules

I have a static website - a bunch of static html pages. I am trying to remove .html part from the URL of my webpages. I have used an .htaccess file with the following code to do that: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %

Yii2: remove the URL controller

I am using the advanced template. I created all my actions on the SiteController, so all my urls are domain.com/site/something, and I need to remove the word "site" from the url so it will be domain.com/something. I tried the following rules bas

500 Server error with Plesk, NGINX, PHP-FPM when removing the URL slash

I'm running into an extremely bizarre error while running a WordPress site. WordPress has permalinks turned on. The 500 server error occurs when you REMOVE the trailing slash (/) from the URL. For example: www.site.com/about/ -> works fine. www.site.

sed to remove the url from the file

I am trying to remove in-place a specific url from a file using sed and currently the command below runs but the url is still in the file. Thank you :) list xxxx://www.xxx.com/xxx/xx/xxx/file.html xxxx://www.xxx.com/xxx/xx/xxx/file1.bam xxxx://www.xx

Using .htaccess to remove the URL folder

I have a Laravel app, and the document root of host is configured at Laravel root folder (upper directory of public). I tried the following .htaccess to silently rewrite URLs, but it keeps redirecting me to /public, instead of showing domain URL and

How to remove Query String & ldquo ;? & Rdquo; (question mark) from the URL (Using Wordpress)

I was using wordpress 3.3 to power my website. I tested it with Page Speed and it gave me error "remove query string from URL).... The query string is a question mark which appears in the start of query paramter of the url..... http://gizmocube.com/i

to hide / remove the url extension in Windows servers

I read that .htaccess doesn't work on windows server like godaddy. So to hide or remove extensions like .php and .html on URL, you can accomplish this by creating a web.config file with the following code: <configuration> <system.webServer> &l

Remove the url prefix SLUG = from the URL

how can i remove prefix url value i.e slug= from the url is there any process please assist if there is i tried using str_pos but does not work my url is http://localhost/blog/?slug=what-is-lorem-ipsum what i expect http://localhost/blog/what-is-lore

When trying to remove the URL from the website from the selected pages / messages

website : http://www.otislandscapedesign.com/ I am trying to remove the website title from the following selected pages/posts using id : category-portfolio clients about contact I've tried the following css code out of pot luck but no cigar .postid-5

Remove the url search bar from Android / iPhone

I have got a table, on a page: <table border="0" width="320px" height="480px" style="background-color: black;"> UPDATE: I want to remove the search bar above... so this is all I used for the adaptation for the

One way to remove the url added from the url parameter in $ .ajax for jquery

I am using cakephp and want to use the jQuery.ajax to post to my server. The issue is jQuery's $.ajax appends the protocol and hostname, but also includes the current controller, so I cannot change the controller I am pasting too. Is there a way to c

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK