• Hi,

    I’ve run into some problems while trying to organise posts in a slightly unorthodox manner.

    I have one type of url for viewing a selection of posts

    /category/thread

    where category is, yes, a category of posts. Thread is sort of a context that can be a tag, an author or any custom query. Using the following rewrite rule I can access the thread variable from the querystring and get the posts for that thread in my category.php template file.

    'category/([a-z]+)/?$' => 'index.php?category_name=category&thread=$matches[1]'

    This works nicely! The troubles begin when I try to view a single post in a thread. I would like to use the following url

    /category/123/thread (or possibly /category/thread/123)

    where 123 is the ID of a selected post.

    However, when I try

    'category/([0-9]+)/([a-z]+)$' => 'index.php?p=$matches[1]&thread=$matches[2]'

    I always end up on /category/123 and the querystring “thread” variable is not accessible. I suspect I’m being redirected by another rule?

    Any pointers as to how I can arrive at the single post view template with both url and querystring intact is greatly appreciated!

    /Erik

    PS. I got the url structure right by using category_name instead of p and adding another variable to the query string (curr_id) with the selected post ID:

    'category/([0-9]+)/([a-z]+)$' => 'index.php?category_name=category&curr_id=$matches[1]&thread=$matches[2]'

    But then I run into new trouble when using comments, being redirected to /category/123 after submitting the comment. I have a nagging feeling that I’m overcomplicating things – that there is a way to do what I want that is more aligned with WordPress existing structures.

  • The topic ‘Custom rewrites and querystring issues’ is closed to new replies.