I created a custom URL parameter for sorting posts by their vote scores. I have a “most voted” link that sends a ?sort=most_voted
URL paramater and using a query posts filter I display posts with most votes.
If for instance I want to display most voted posts in category 5, I’ll need a URL like this ?cat=5&sort=most_votes
How do I preserve/attach the sort
parameter in the URL when browsing categories (or even by tag name, search, etc)?
You will need to intercept the links generated by WordPress and append the query var onto the relevant URLs.
You can do this quite easily with a filter on category URLs with something like…
I also spotted this handy list of filters on Mike’s post on SO, it should cover all the possible URLs you’d want to tweak the query vars for…
Hope that helps..
You can make use of the add_query_arg() (WordPress Function) to add an additional parameter to the query (or also called query-info) part of an URL.