Remove the taxonomy base of the URL in WordPress
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
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
Javascript alert indicating the URL of the site. How do I remove the URL from the site at the top of the javascript alert?
.htaccess: redirect the URL from the root to the subdirectory, but remove the URL from the root
.html Removing the URL Using the .htaccess Rewrite Rules
Yii2: remove the URL controller
500 Server error with Plesk, NGINX, PHP-FPM when removing the URL slash
sed to remove the url from the file
Using .htaccess to remove the URL folder
How to remove Query String & ldquo ;? & Rdquo; (question mark) from the URL (Using Wordpress)
to hide / remove the url extension in Windows servers
Remove the url prefix SLUG = from the URL
When trying to remove the URL from the website from the selected pages / messages
Remove the url search bar from Android / iPhone
One way to remove the url added from the url parameter in $ .ajax for jquery
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK