Support » Fixing WordPress » Page Excerpt Outside the Loop

  • I need to show various excerpt from specific pages..

    I found this code:

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

    But I’m not sure how to use it.. I tried
    <?php echo get_the_excerpt_here(12); ?>

    but it doesn’t work..

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Page Excerpt Outside the Loop’ is closed to new replies.