Title: get_posts array
Last modified: August 20, 2016

---

# get_posts array

 *  [yoxalld](https://wordpress.org/support/users/yoxalld/)
 * (@yoxalld)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/get_posts-array/)
 * I am trying to access the get_posts array and pull the information I need from
   it. I need to put the thumbnails from the posts i am getting in one section and
   the content in another. What I need to do is also pull the permalink to each 
   post but there doesn’t seem to be a way to do that with the get_posts array. 
   Here is the code I have
 *     ```
       <?php
       	$args = array( 'numberposts' => 3 );
       	$lastposts = get_posts( $args );
       	//print_r($lastposts[0]);
       	$one = $lastposts[0];
       	$two = $lastposts[1];
       	$three = $lastposts[2];
       ?>
       ```
   
 * Then I put the content into divs like this:
 *     ```
       <div id="caption1" class="nivo-html-caption" >
       	<h2><?php print $one->post_title;?></h2>
       	<p><?php print substr($one->post_content,0,300) ;?>...</p>
       </div><!--caption1-->
   
       <div id="caption2" class="nivo-html-caption" >
       	<h2><?php print $two->post_title;?></h2>
       	<p><?php print substr($two->post_content,0,300) ;?>...</p>
       </div><!--caption2-->
       ```
   
 * But $one->post_permalink; isn’t a valid object interface. Any idea how I can 
   get the link the each post in the p tag after the_content? Thanks
 * _[Please post code or markup snippets between backticks or use the code button.]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/get_posts-array/#post-2597029)
 * check the docu
 * [http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)
 * and:
 * [http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail](http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail)
   
   [http://codex.wordpress.org/Function_Reference/get_permalink](http://codex.wordpress.org/Function_Reference/get_permalink)
 *  Thread Starter [yoxalld](https://wordpress.org/support/users/yoxalld/)
 * (@yoxalld)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/get_posts-array/#post-2597053)
 * Thanks, I didn’t think about passing the post id from the get_posts array into
   the get_permalnk function. That should work just fine. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘get_posts array’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)
 * [permalink](https://wordpress.org/support/topic-tag/permalink/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [yoxalld](https://wordpress.org/support/users/yoxalld/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/get_posts-array/#post-2597053)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
