Title: Recent posts, calling a function &quot;the_category&quot;
Last modified: August 20, 2016

---

# Recent posts, calling a function "the_category"

 *  [Jonyks](https://wordpress.org/support/users/jonyks/)
 * (@jonyks)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/recent-posts-calling-a-function-the_category/)
 * I use the following code to display the recent posts.
 *     ```
       <?php
         $args = array( 'numberposts' => '5' );
         $recent_posts = wp_get_recent_posts( $args );
         foreach( $recent_posts as $recent ){
         echo '<li>
         <a class="permalink" href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a>
         <span class="category">Posted in ??????</span>
               </li> ';
       	}
       ?>
       ```
   
 * how to call function “the_category” and use it instead of “??????” ?
 * Regards

Viewing 1 replies (of 1 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/recent-posts-calling-a-function-the_category/#post-2856928)
 * Um – you might be better off using [get_posts()](http://codex.wordpress.org/Function_Reference/get_posts)
   or [WP_Query](http://codex.wordpress.org/Function_Reference/WP_Query) instead
   of wp_get_recent_posts.

Viewing 1 replies (of 1 total)

The topic ‘Recent posts, calling a function "the_category"’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [the_category](https://wordpress.org/support/topic-tag/the_category/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/recent-posts-calling-a-function-the_category/#post-2856928)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
