Viewing 3 replies - 1 through 3 (of 3 total)
  • Dear @ollietubb1

    Yes, that’s possible for that you need to change your permalink, please check the screenshot below to know how to do that.

    https://prnt.sc/NscTfshmO2iG

    Thank you.

    Thread Starter ollietubb1

    (@ollietubb1)

    Hey Rashed,

    Thanks for your response and solution. I tried it but unfortunately it updated the URL but then the pages could not be found. I guess it was still looking for /product . I have reverted back for now.

    Many thanks,
    Ollie

    Dear @ollietubb1 
    
    You can try this code
    
    function change_woocommerce_product_slug($args, $post_type) {
    
    if ($post_type == 'product') {
    
    $args['rewrite']['slug'] = 'campaigns'; // Replace 'campaigns' with your desired slug
    
    }
    
    return $args;
    
    }
    
    add_filter('register_post_type_args', 'change_woocommerce_product_slug', 10, 2);
    
    function change_woocommerce_rewrite_rules($rules) {
    
    foreach ($rules as $key => $rule) {
    
    if (strpos($key, 'product') !== false) {
    
    unset($rules[$key]);
    
    }
    
    }
    
    return $rules;
    
    }
    
    add_filter('rewrite_rules_array', 'change_woocommerce_rewrite_rules');
    
    function change_woocommerce_product_link($post_link, $post) {
    
    if (is_object($post) && $post->post_type == 'product') {
    
    return str_replace('product', 'campaigns', $post_link);
    
    }
    
    return $post_link;
    
    }
    
    add_filter('post_type_link', 'change_woocommerce_product_link', 10, 2);
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change ‘product’ to ‘campaign’ in URL and slugs’ is closed to new replies.