WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my single template, I wish to show other posts in that category.
Its essential that I use the route they chose, i.e. if they clicked Category 1, then Post A, if Post A is also Categorised as Category 2 and Category 3, I only want to show posts from Category 1 because that is what they originally chose.

Is this an option? Is there a way to store some sort of global variable which I can set on my category page, then utilise on my single page?

share|improve this question
Could you go back through your questions and accept any correct answers? a 0% acceptance rate isn't going to get you any answers =( – Tom J Nowell Mar 29 '12 at 14:52
okay, if it'll get me an answer! Though I only accept answers where I actually get a good answer. Out of my 4 other questions, only 1 deserved the correct answer tick. Though, if it'll appease you, we're now at 100% – Dan Hanly Mar 29 '12 at 14:58
If it answers the question then it should be accepted, there's nothing stopping you switching if a better answer comes along – Tom J Nowell Mar 29 '12 at 15:18
And if ti isn't good enough you should comment and explain why so the person answering can ammend the answer (maybe they misunderstood?) – Tom J Nowell Mar 29 '12 at 15:19
Yeah, I know how it works, I've been a member of SO and other SE sites for a couple of years. Though as I don't use this one as much I tend to forget. They're done now. Can you help? – Dan Hanly Mar 29 '12 at 15:29
up vote 1 down vote accepted



Which will give you:


Which you can then put into any queries you make under category-name.

You can see this in action using the Monkeyman rewrite analyser plugin, by entering one of the URLs for a post and seeing the query variables it generates using those rules

share|improve this answer
Thanks for this! I should forget to mark you as correct just for the fun of it now ;-p – Dan Hanly Mar 29 '12 at 16:24
haha you wouldn't dare =p – Tom J Nowell Mar 29 '12 at 16:28
Could you post more details on how to implement this? Where code goes, which template etc? – drivebass Sep 2 '12 at 7:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.