WordPress.org

Ready to get started?Download WordPress

Forums

Recent posts, calling a function "the_category" (2 posts)

  1. Jonyks
    Member
    Posted 2 years ago #

    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

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Um - you might be better off using get_posts() or WP_Query instead of wp_get_recent_posts.

Topic Closed

This topic has been closed to new replies.

About this Topic