WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] An excerpt of recent post outside the loop?

[Resolved] An excerpt of recent post outside the loop?

  • estevancarlos
    Member

    @estevancarlos

    How do I load an excerpt of the a recent blog post and use it outside the loop? I found a useful function but it requires specifying the ID of the post.

    http://www.lonewolfdesigns.co.uk/excerpt-loop/

    function get_the_excerpt_here($post_id)
    {
      global $wpdb;
      $query = "SELECT post_excerpt FROM wp_posts WHERE ID = " . $post_id . " LIMIT 1";
      $result = $wpdb->get_results($query, ARRAY_A);
      return $result[0]['post_excerpt'];
    }

    I just want the most recent post.

    Is there a way I can use this for my specified needs? Or any other suggestions?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] An excerpt of recent post outside the loop?’ is closed to new replies.