Reputation: 3738
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.
Upvotes: 1
Views: 5276
Reputation: 566
use this plugin https://github.com/alexvornoffice/remove-taxonomy-base-slug, what this does? It removes base slug from all taxonomies, and check if the slug is the same as post type slug, and rewrites the rules in the such way so the taxonomy slug will have a better priority over post type slug.
Upvotes: 0
Reputation: 2612
Try this
Just drop it into wp-content/plugins
and activate. It is in the process of being added to the WP repository.
Upvotes: 0
Reputation: 2849
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.
Upvotes: 0