• Resolved cw17s0n

    (@cw17s0n)


    I have my query set up and I can print out the array that should be going to get_posts and see, Array ( [0] => 309 [1] => 10 ), and those are the correct id’s of the posts that should display, but no posts actually show, any help is much appreciated.

    Here is a pastebin of my code: http://pastebin.com/pZkQCf9y

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi,
    Try wp_query($args);

    Construct Like:

    <?php
    $args = array('post__in' => $promotion_ids, 'numberposts' => 5, 'post_status' => 'publish');
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query( $args );
    if ( $wp_query->have_posts() ) :
        while ( $wp_query->have_posts() ) :
            $wp_query->the_post();
        endwhile;
    endif;
    ?>

    HTH

    David

    Thread Starter cw17s0n

    (@cw17s0n)

    Thanks David, what I’ve done is below, yet I still get nothing showing up.

    [code moderated - the forum limit is 10 lines of code - for more, please use the pastebin]

    Change the endif for an else with a message to make sure the posts are returned!

    <?php endwhile; ?>
    <?php else : ?>
    	<p>No results were found</p>
    <?php endif; ?>
    Thread Starter cw17s0n

    (@cw17s0n)

    Hmm, no results were found.

    Thread Starter cw17s0n

    (@cw17s0n)

    Is Array ( [0] => 309 [1] => 10 ) properly formatted to be entering into a query? Or does it need to just be 309, 10.

    Try a hard code to see if the posts are returned

    $args = array('post__in' => array( 309, 10 ) );

    Also do you need the post type as well

    'post_type' => 'promotions',

    David

    Thread Starter cw17s0n

    (@cw17s0n)

    It was missing ‘post_type’ Thanks for your efforts.

    $args = array(
    	'post_type' => 'promotions',
    	'post__in' => $promotion_ids,
    	'numberposts' => 5,
    	'post_status' => 'publish'
    );

    Posted the same question!

    David 😉

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Issues displaying an array of posts’ is closed to new replies.