• I’m making a WordPress theme. I made a grid structure shown below,

    http://i.stack.imgur.com/QOiNk.jpg

    It contains two rows, and every row has three columns. I want to show random posts from my WordPress database in this grid.

    This is my code

    <div class=”row”>
    <div class=”col-xs-12″>
    <div class=”rst-mediagrid”>
    <div class=”div”>
    <?php
    $args = array(
    ‘posts_per_page’ => 6,
    ‘offset’ => 0,
    ‘category’ => ‘2’,
    ‘category_name’ => ”,
    ‘orderby’ => ‘date’,
    ‘include’ => ”,
    ‘exclude’ => ”,
    ‘meta_key’ => ”,
    ‘meta_value’ => ”,
    ‘post_type’ => ‘post’,
    ‘post_mime_type’ => ”,
    ‘post_parent’ => ”,
    ‘author’ => ”,
    ‘post_status’ => ‘publish’,
    ‘suppress_filters’ => true
    );

    global $post;
    $post = get_post($args);

    $next_post = get_adjacent_post( true, ”, false, ‘taxonomy_slug’ );
    ?>
    <div class=”rst-col rst-col-50″>
    <div class=”rst-postpic”>
    <?php echo get_the_post_thumbnail($post->ID); //latest post thumbnail ?>
    </div>
    </div>
    <?php //endif; ?>

    <div class=”rst-col rst-col-25″>
    <div class=”rst-postpic rst-postvideo”>
    <?php echo get_the_post_thumbnail($next_post->ID); ?>
    </div>
    </div>

    <div class=”rst-col rst-col-25″>
    <div class=”rst-postpic”>
    <?php echo get_the_post_thumbnail($next_post->ID); ?>
    </div>
    </div>

    <div class=”clear”></div>
    </div>
    <div class=”div”>
    <div class=”rst-col rst-col-25″>
    <div class=”rst-postpic”>
    <?php echo get_the_post_thumbnail($next_post->ID); ?>
    </div>
    </div>
    <div class=”rst-col rst-col-25″>
    <div class=”rst-postpic rst-postvideo”>
    <?php echo get_the_post_thumbnail($next_post->ID); ?>
    </div>
    </div>
    <div class=”rst-col rst-col-50″>
    <div class=”rst-postpic”>
    <?php echo get_the_post_thumbnail($next_post->ID); ?>
    </div>
    </div>
    <div class=”clear”></div>
    </div>
    </div>
    </div>
    </div>

    The above code repeats the same image that I want to show thumbnails for in a perfect order, like the first row has three columns, and the first column has the latest image second column has image of previous post and third column has image of previous of previous mean 3rd post from latest post and second row also has same things.

    If you have better suggestion kindly tell me.

  • The topic ‘How to show Next Post using current Id in WordPress?’ is closed to new replies.