WordPress.org

Forums

Rewrite Rules Inspector
[resolved] rewrite rule applies to pages although it shouldn't (6 posts)

  1. chacha2000
    Member
    Posted 2 years ago #

    Hi!
    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 :
    ([^/]+)/?$
    index.php?custom_tag_not_for_pages=$matches[1]
    custom_post_type
    ////////////////////////////////////////////////
    (.?.+?)(/[0-9]+)?/?$
    index.php?pagename=$matches[1]&page=$matches[2]
    page
    ////////////////////////////////////////////////
    ([^/]+)(/[0-9]+)?/?$
    index.php?name=$matches[1]&page=$matches[2]
    post
    ////////////////////////////////////////////////
    Do you know for what possible reason this could be happening?
    Any help would be much appreciated ! thanks !

    http://wordpress.org/extend/plugins/rewrite-rules-inspector/

  2. chacha2000
    Member
    Posted 2 years ago #

    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?

  3. Daniel Bachhuber
    Hand Built
    Plugin Contributor

    Posted 2 years ago #

    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:

    http://vip.wordpress.com/documentation/remove-the-slug-from-your-custom-post-type-permalinks/

  4. chacha2000
    Member
    Posted 2 years ago #

    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!

  5. Daniel Bachhuber
    Hand Built
    Plugin Contributor

    Posted 2 years ago #

    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.

  6. chacha2000
    Member
    Posted 2 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Rewrite Rules Inspector
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic