Title: Latest posts with javascript
Last modified: August 19, 2016

---

# Latest posts with javascript

 *  [Xavvi](https://wordpress.org/support/users/skinny-latte/)
 * (@skinny-latte)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/latest-posts-with-javascript/)
 * Hello,
 * I am trying to pull the 3 most recent posts from my portfolio category and apply
   this javascript code to them ([http://buildinternet.com/2009/03/sliding-boxes-and-captions-with-jquery/](http://buildinternet.com/2009/03/sliding-boxes-and-captions-with-jquery/))
   on my front page. These posts need to have an image as well- all put in using
   a custom field of bigimg.
 * So far I’ve only managed to get the **same last post 3 times**! I know how to
   get the last 3 most recent posts….but I don’t understand how to make them each
   go into the separate divs and each use the javascript. I need the last 3 most
   recent posts with their own bigimg, title and permalink. I am reluctant to use
   more than one custom field for the bigimg (eg bigimg1, bigimg2, bigimg3) as I
   would then have to change the positions of each post every time I wanted to put
   a new one in. I know this is a long post but can anybody please help? I’m sure
   it can’t be difficult, I’m probably just doing something stupid wrong…
 * Here is my code:
 *     ```
       <?php $recent = new WP_Query("category_name=portfolio&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
   
       <div class="boxgrid captionfull">
   
       <?php $bigimg = get_post_meta($post->ID, 'bigimg', true); ?>
       <img src="<?php echo $bigimg ?>" alt="<?php the_title(); ?>" border="0" /></a>
       <div class="cover boxcaption">
       <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
   
       </div>
       </div>
   
       <div class="boxgrid captionfull">
   
       <?php $bigimg = get_post_meta($post->ID, 'bigimg', true); ?>
       <img src="<?php echo $bigimg ?>" alt="<?php the_title(); ?>" border="0" />
       <div class="cover boxcaption">
       <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
   
       </div>
       </div>
   
       <div class="boxgrid captionfull">
   
       <?php $bigimg = get_post_meta($post->ID, 'bigimg', true); ?>
       <img src="<?php echo $bigimg ?>" alt="<?php the_title(); ?>" border="0" />
       <div class="cover boxcaption">
       <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
   
       </div>
       </div>
       ```
   
 * Is it something to do with getting the last post but one, last post but two etc
   etc? Can anybody help? Coding is not my strong point!

The topic ‘Latest posts with javascript’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [Xavvi](https://wordpress.org/support/users/skinny-latte/)
 * Last activity: [17 years, 2 months ago](https://wordpress.org/support/topic/latest-posts-with-javascript/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
