1

What I want to do is get the ID's of all posts inside a custom post type. I'm using this code, however it seems to be stuck in an infinite loop.

$query = new WP_Query(array('post_type' => 'rdv-events', 'posts_per_page' => -1));

while ($query->have_posts()) {
    $values = get_post_custom();
    print_r($values);
}

wp_reset_postdata();

People place a shortcode on the site and then I want to use this to loop through some events and then echo then out. Maybe not important, but it was worth mentioning :)

Can anyone help me out? Thanks!!

1 Answer 1

17

You missed

$query->the_post();

Put it first in the while loop.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow. That little bit is left out of many WP_Query examples out there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.