Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using WooCommerce for a shopping site and it is adding slug or base to the urls. For instance:

I don't want slug/base (product & product-category) in urls.

Is there any way or plugins to remove them from urls?

share|improve this question

closed as off-topic by toscho Apr 17 '14 at 19:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

I'm looking for the same answer. The problem is "product-category" is the default setting. I did a grep through all the files for "product-category" and still can't figure it out. There's no "product-category" in .htaccess either. IMO, this is a Wordpress question, as the plugin depends on WordPress permalink settings. And it's not like Woocommerce is an obscure plugin. – PJ Brunet Aug 6 '14 at 17:01

1 Answer 1

up vote 1 down vote accepted

Found this neat little article on it, try this out!

It's a guide/tutorial, so you should be able to get more information on what's going on here if you visit his site.

By the way, it's against the rules to ask for a plugin here.


function custom_pre_get_posts($query) {
    global $wpdb;

    if(!$query->is_main_query()) {

    $post_name = $query->get('pagename');

    $post_type = $wpdb->get_var(
        'SELECT post_type FROM ' . $wpdb->posts . ' WHERE post_name = %s LIMIT 1',

    switch($post_type) {
      case 'services':
        $query->set('services', $post_name);
        $query->set('post_type', $post_type);
        $query->is_single = true;
        $query->is_page = false;

    return $query;
share|improve this answer
Thanks it help me in some way to find the solution. – Irfan Dayan Jan 20 '14 at 7:47
Great, I'm glad I could help. It's amazing what Google can turn up if you find the right query. – MrJustin Jan 20 '14 at 9:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.