• yoxalld

    (@yoxalld)


    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)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_posts array’ is closed to new replies.