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

I'm looking for a way to query posts by id, and using a string as a parameter, instead of an array. Like this:


But I need to get multiple posts. For example with ID 153 and 154. How would I do that with a string as a parameter?

The reason that I'm using a string is because I'm generating that string with javascript and if I would do it otherwise it will get super complicated.

Any ideas?

share|improve this question
up vote 0 down vote accepted

You could convert the string to an array using the php explode function. So if you used a comma as your delimiter, you could pass the string '153,154,87' and that would and then use the explode function to convert it to


If you want to keep the p= you could use str_replace etc.

share|improve this answer

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.