Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
412 views
in Technique[技术] by (71.8m points)

wordpress - Why are my Woocommerce permalinks conflicting with main website pages?

Was wondering if someone could point me in the right direction.

My current Woocommerce Permalink settings are as follows:

SHOP www.mywebsite.com/shop

SHOP WITH SUB CATEGORY www.mywebsite.com/seasons/winter

Unfortunately, the above SHOP WITH SUB CATEGORY link also works without the product category - i.e. www.mywebsite.com/winter - for some reason.

Which is annoying as I also have a main page in my website called Winter. (i.e. mywebsite.com/winter).

I have tried various versions of the COMMON, OPTIONAL and PRODUCT permalinks, but no matter what I type, www.mywebsite.com/winter always points to the Woocommerce Shop page and not the normal website page.

Any ideas?

Huge thank you in advance :) Steven

question from:https://stackoverflow.com/questions/65907209/why-are-my-woocommerce-permalinks-conflicting-with-main-website-pages

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What happens when you use this? This code stops WordPress from guessing where to go.

function no_redirect_guess_404_permalink( $header ){
    global $wp_query;

    if( is_404() )
        unset( $wp_query->query_vars['name'] );

    return $header;
}

add_filter( 'status_header', 'no_redirect_guess_404_permalink' );

Original answer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...