WordPress.org

Forums

latest post thumbnail (6 posts)

  1. vanhansen
    Member
    Posted 3 years ago #

    Hello World!

    I got three divs.. inside each div I want last post, second last post and then third last post.

    so:

    <div id="box1">last post</div>
    <div id="box2">second last post</div>
    <div id="box3">third last post</div>

    I want to get the title and an image from that post. I want to code it my self, and not use a plugin for it. I want it to dynamically update it self..

    I'm not too familiar with php, yet. So go easy on me.

    I also want it to be clickable and take the visitors to the post. actually, I need the boxes to take the visitor to three specific places on the same page, smoothly. (Dont mind the js, I'll deal with that later).

    I've been googling a bit, but I really dont know where to look or what to look for. So a little point in the right direction and some advice would be VERY helpful!

  2. keesiemeijer
    moderator
    Posted 3 years ago #

    I want to get the title and an image from that post.

    Is that the featured image (Post Thumbnail) you want or the first image in the post?

  3. keesiemeijer
    moderator
    Posted 3 years ago #

    try it with a query to a loop:
    http://codex.wordpress.org/Function_Reference/query_posts
    http://codex.wordpress.org/Function_Reference/WP_Query

    example:

    <?php
    $the_query = new WP_Query( 'posts_per_page=3');
    while ( $the_query->have_posts() ) : $the_query->the_post();
    ?>
    <div id="box<?php echo $the_query->current_post+1; ?>">
    <?php
    if ( has_post_thumbnail($post->ID) ) { // check if the post has a Post Thumbnail assigned to it.
      the_post_thumbnail($post->ID);
    }
    ?>
    <?php the_title(); ?>
    </div>
    <?php endwhile; ?>
  4. vanhansen
    Member
    Posted 3 years ago #

    I'll try it, I'll get back to this after I fix my current problem :P Thank you Keesiemeijer-

  5. Mobilepriceinindia
    Member
    Posted 3 years ago #

    Hi ..
    i have uploaded Arras theme in my blog and i want know that how to implement recent post in search page as well as archive as .

    Thanks in advance
    my blog address is http://www.mobilepriceupdate.com

  6. esmi
    Forum Moderator
    Posted 3 years ago #

    Try asking on the theme's dedicated forum: http://www.arrastheme.com/forums/

Topic Closed

This topic has been closed to new replies.

About this Topic