• Basically the result I need is to get the excerpt for a post (or ‘faked’ excerpt) by supplying a content_id. Unfortunately the_excerpt() does not accept any arguments. So the following doesn’t work.

    <?php
      $my_id = 7;
      the_excerpt($my_id);
    ?>

    Any ideas anyone?

Viewing 3 replies - 1 through 3 (of 3 total)
  • What is the content in which you want to use this? It is always possible to grab data with query_posts or just cook up a MySql query and use $wpdb->get_results, but depending upon context there might be other ways.

    Thread Starter Marc Smits

    (@ctrlspatie)

    I use EventCalendar3 and which displays 3 upcoming events in my sidebar. For every event I need about 60 characters of the posts’ text.

    <?php substr($myexcerpt, 0, 60); ?>

    So I want only the text from a post, otherwise it might cause it display HTML-code in the sidebar.

    query_posts is an option, but how do I get WordPress to filter it?

    Could try:

    <?php
    $postidtoget = 1;
    $mypost = get_post($postidtoget);
    //echo "<pre>"; print_r($mypost); echo "</pre>";
    echo '<p> excerpt' . $mypost->post_excerpt . '</p>';
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I get the excerpt of a post outside the_Loop’ is closed to new replies.