Title: Creating Info Boxes Using Posts
Last modified: February 7, 2018

---

# Creating Info Boxes Using Posts

 *  Resolved [cdeuro](https://wordpress.org/support/users/kykana/)
 * (@kykana)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/creating-info-boxes-using-posts/)
 * I’m trying to “embed” specific posts onto my frontpage so that they show up in
   boxes and look like the image below:
     If images doesn’t show up click this link:
   [https://1drv.ms/i/s!ArYmkC4cbVhGpDobeKBCODJT4fKe](https://1drv.ms/i/s!ArYmkC4cbVhGpDobeKBCODJT4fKe)
 * On past websites I’ve used the following code to show a list of posts from specific
   categories but how do I change this show the content of the specific posts?
 *     ```
       <ul>
       <?php
       $args = array( 'category' => 2, 'numberposts' => '5', 'post_status' => 'publish', 'tax_query' => array(	) );
       $recent_posts = wp_get_recent_posts( $args );
       foreach( $recent_posts as $recent ){
       echo '<li><h5><a href="'.get_permalink($recent["ID"]) . '">'.( __($recent["post_title"])).'</a></h5> <p>'.( __($recent["post_excerpt"])).'</p></li> ';
       }
       wp_reset_query();
       ?>
       </ul>
       ```
   
    -  This topic was modified 8 years, 3 months ago by [cdeuro](https://wordpress.org/support/users/kykana/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcreating-info-boxes-using-posts%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [8 years, 3 months ago](https://wordpress.org/support/topic/creating-info-boxes-using-posts/#post-9950342)
 * Modify your code to wrap each post in a `<div>` and output the various pieces
   of the post within. The rest is just CSS to make it look nice.
 * Look at these functions in the codex: the_content, the_title, the_excerpt, the_post_thumbnail
 *  Thread Starter [cdeuro](https://wordpress.org/support/users/kykana/)
 * (@kykana)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/creating-info-boxes-using-posts/#post-9950787)
 * Thanks [@sterndata](https://wordpress.org/support/users/sterndata/), I was able
   to get the posts to show I wanted them. The only issue I’m having now is that
   the featured images won’t show up. I’ve looked through the documentations, through
   people’s examples, but I can’t figure out the correct combination. Here’s my 
   website: [http://medicalinheritance.com/testing/](http://medicalinheritance.com/testing/)
 * I’m using i-Craft as my base theme. I’ve gone through the settings and the code,
   I can’t find anything that might be preventing them from showing up.
 *     ```
       <ul>
       <?php					
       $args = array( 'category' => 20, 'numberposts' => '3', 'post_status' => 'publish', 'tax_query' => array(	) );
       $recent_posts = wp_get_recent_posts( $args );
       if ( has_post_thumbnail()) {
       $recent_thumb = get_post_thumbnail_id($recent_posts);
       }
       foreach( $recent_posts as $recent ){
       echo '<li>'.the_post_thumbnail( $recent_posts ).'
       <h2>'.( __($recent["post_title"])).'</h2> <p>'.( __($recent["post_content"])).'</p></li> ';
       }
       wp_reset_query(); 
       ?>
       </ul>
       ```
   
    -  This reply was modified 8 years, 3 months ago by [cdeuro](https://wordpress.org/support/users/kykana/).
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [8 years, 3 months ago](https://wordpress.org/support/topic/creating-info-boxes-using-posts/#post-9952864)
 * the_post_thumbnail() works only in “the loop” and takes size as a parameter. 
   You’ll need to use [https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/](https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/)
   instead. See the examples on that page.
 *  [harshclimate](https://wordpress.org/support/users/harshclimate/)
 * (@harshclimate)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/creating-info-boxes-using-posts/#post-9953136)
 * [@sterndata](https://wordpress.org/support/users/sterndata/) Can the post thumbnail
   accept parameters that he has specified? I didn’t know you could do that…
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [8 years, 3 months ago](https://wordpress.org/support/topic/creating-info-boxes-using-posts/#post-9953148)
 * Harsh: I’m not exactly sure what you’re asking. Please review the codex article
   on post thumbnails.
 *  Thread Starter [cdeuro](https://wordpress.org/support/users/kykana/)
 * (@kykana)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/creating-info-boxes-using-posts/#post-9954888)
 * Got it to work!! ^_^
 *     ```
       <?php while ( have_posts() ) : the_post(); ?>
       <ul>
       <?php 
       $posts = get_posts( array( 'posts_per_page' => 5 ) );
       foreach ( $posts as $_post ) {
       if ( has_post_thumbnail( $_post->ID ) ) {
       echo '<li><h5><a href="'.get_permalink($_post->ID) . '">'.( __($_post->post_title)).'</a></h5>'.get_the_post_thumbnail( $_post->ID, 'thumbnail' ).'<p>'.( __($_post->post_content)).'</p></li>';
       }
       }
       ?>
       </ul>
       <?php endwhile; ?>
       ```
   
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [8 years, 3 months ago](https://wordpress.org/support/topic/creating-info-boxes-using-posts/#post-9954895)
 * Woo Hoo!

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

The topic ‘Creating Info Boxes Using Posts’ is closed to new replies.

## Tags

 * [arrays](https://wordpress.org/support/topic-tag/arrays/)
 * [pages](https://wordpress.org/support/topic-tag/pages/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 7 replies
 * 3 participants
 * Last reply from: [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/creating-info-boxes-using-posts/#post-9954895)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
