Support » Plugin: Rewrite Rules Inspector » rewrite rule applies to pages although it shouldn't

  • Resolved chacha2000


    I don’t know if you could help me with this : I have identified a problem with my ‘page’ post type (the default wordpress pages). Somehow it “picks up” a rewrite rule that should not be applied to it. And when i specify any page in the “match URL” field of your plugin i get these 3 rewrite rules :
    Do you know for what possible reason this could be happening?
    Any help would be much appreciated ! thanks !

Viewing 5 replies - 1 through 5 (of 5 total)
  • Apparently it has something to do with the fact that the slug (rewrite) defined for some of my custom post types begins with that “%custom_tag_not_for_pages%”; because if i change the slug to “test/%custom_tag_not_for_pages%” everything works fine… but i don’t want to write anything in front of %custom_tag_not_for_pages% :/

    Actually it seems that the pages are trying to use any %tag% used at the beginning of the slug for any of my custom post types… how to prevent them from doing that?

    Plugin Contributor Daniel Bachhuber


    I think the problem is that your CPT rewrite rule declaration is taking priority over pages.

    In order to have your CPT use /post-name/ slugs like your posts and pages, you’ll need a bit of additional code. I’ve documented it here:

    Hi! Thanks for your answer !
    I tried your code but i’m still not there..
    What i’m trying to do is not to get rid of the slug, but to build a cutom one, with variations depending on the type of the custom post type, whether the post has a parent or not, belongs to one category or another, etc…
    But if i replace the “/” in here : $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); with something else, i get 404’s… The structure is right in the adress bar etc… but i get 404’s. I tried with $post_link = str_replace( '/' . $post->post_type . '/', '/test/', $post_link ); but same thing : 404. How can i replace the ‘/’ and get my pages working right?
    Thanks again for taking the time to look into my problem!

    Plugin Contributor Daniel Bachhuber


    It sounds like you might need a bit of developer help then. This is outside the scope of the support we offer for the plugin.

    Hi! Yes, indeed, this has nothing to do with the plugin itself, i just used the plugin to identify what was going on, and posted in “plugins and hacks” with a link to the plugin because i thought it was the most appropriate place to post and get some help from the community!
    If anyone reads this and has any idea of why the pages “pick up” the first part of the custom tag from my custom post type slug rewrite, please let me know ! (my custom post type slugs look like this : %something%/%something_else%/%another_thing%
    The pages pick up the “%something%” and therefore, don’t work anymore (the home page gets loaded instead). But if i put something in front of that %something% in my slug rewrite, it works ! even if i put a small dash sign and the rewrite slug becomes -%something%/%something_else%/%another_thing% it works just fine ! But i don’t want anything in front, and most inportantly, i’d like to understand why pages behave this way ! Does anyone have a clue?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘rewrite rule applies to pages although it shouldn't’ is closed to new replies.