I have a short query that is supposed to load IDs from pages that the user picks in the backend. Currently it does display an array with IDs on the frontpage, but it stops displaying posts after the first one.
Code that I use to get the IDs from the field:
<?php
$value = get_field('event_hotels', false);
var_dump($value);
$print = implode(',', $value);
echo $print;
?>
This outputs '158,67,136,153' in my example.
Next, I load this into a WP Query:
$args = array('post_type' => 'hotel', 'p' => $print, 'posts_per_page' => 20, 'orderby' => 'title', 'order' => 'ASC');
var_dump($args);
$loop = new WP_Query($args);
The output is as follows:
array(6) { ["post_type"]=> string(5) "hotel" ["p"]=> string(14) "158,67,136,153" ["posts_per_page"]=> int(20) ["orderby"]=> string(5) "title" ["order"]=> string(3) "ASC" }
So the 'p' is populated with 4 page IDs just like I wanted, except... only 1 shows up. If I change page IDs for category there is no problem and I see more.
What am I doing wrong?