WordPress.org

Ready to get started?Download WordPress

Forums

pulling a posts data according to its category tag and post order (1 post)

  1. conor909
    Member
    Posted 1 year ago #

    Im creating my own theme for a simple portfolio website.

    I want to have a list of thumbnails from my posts displayed in columns and rows. In order of latest posted.

    I have all my html div elements set up and at the moment they are pulling the same image from the latest post into every div.

    How do I set up the divs so that the first one pulls in the latest post, the second pulls in the second last post.. etc. So it updates automatically when I post a new post.

    At the moment I can pull by date, but thats not dynamic is I post a new one. Here is my code that pulls the latest post..

    <?php
       									 	$args = array( 'numberposts' => 1, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
        									$postslist = get_posts( $args );
        										foreach ($postslist as $post) : setup_postdata($post); ?>
    
                                            <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="imgHolder fullWidth">  <!--MAKE THE IMAGE A LINK TO THE POST-->
    											<?php
    											 if (has_post_thumbnail()) { $image_src = wp_get_attachment_image_src ( get_post_thumbnail_id(), '' ); echo '<img src="' . $image_src[0] . '" width="100%" />'; }
    											 ?>
                                            </a>

Topic Closed

This topic has been closed to new replies.

About this Topic