WordPress.org

Support

Support » How-To and Troubleshooting » Index.php query based on pretty URL?

Index.php query based on pretty URL?

  • Hey guys,

    I have pretty permalinks set up on my site, so that a post that fits under the “deals” type (which is part of a custom taxonomy, not a wp “category”) will have an address such as:

    http://www.site.com/deals/post-title

    What I want to do is make it possible for users to enter “http://www.site.com/deals/” as their URL, and be presented with the regular index.php, except that content is filtered to only display the “deals” posts.

    I know I can do this by setting up a page specifically for that URL and having a specific query that only looks for deals… but I’d rather it all be done via the index page, so that I don’t have to set up a custom page for each different type of content.

    So my question is: how can I tell the wpquery on index.php to filter results based on whether the URL (“http://www.site.com/”) has an additional segment on the end, such as “deals/”?

    I’m familiar with passing php variables in URLs by using the “?” symbol, but in this case I want my URLs to maintain their “pretty” appearance.

    Any help is much appreciated!

    Thanks in advance,
    Hadyn

Viewing 1 replies (of 1 total)
  • Solved.

    It’s all automatic – I just (stupidly) had a custom query in my index.php which I had forgotten about. I’ve removed the query and – presto – it all works as expected!

Viewing 1 replies (of 1 total)
  • The topic ‘Index.php query based on pretty URL?’ is closed to new replies.