Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Slight problem, I have the following code:

$purchaseprodid = $_GET['ids'];
$args = array(
                  'post_type' => 'prizes',
                  'post__in' => array($purchaseprodid)
                  );
                query_posts($args);

                while (have_posts()) : the_post(); 

I am getting comma seperated numbers for id's in a url, and they dont seem to be querying the posts. If I manually type the id's in they work no problem, but just not when using a variable $purchaseprodid.

Any ideas?

Thanks!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You need to explode the string you obtain from $_GET['ids'] into an array, at the moment you a parsing a to string post__in rather than an array of IDs.

Try

$purchaseprodid = isset($_GET['ids']) ? explode(',',$_GET['ids']) : array();

However, you can sometimes run into difficulties using $_GET with WordPress, it's better to use the API provided and register your variable, see this question.

share|improve this answer
    
Thanks! That did it :) –  JamesG Feb 23 '12 at 14:39

Your Answer

 
discard

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.