WordPress.org

Forums

Display snippets of pages on homepage (2 posts)

  1. matthisco
    Member
    Posted 3 years ago #

    Hi Folks,

    I'm trying to display snippets of pages on my homepage using the code below, but it doesnt display anything, can anyone please help?

    function robins_get_the_excerpt($post_id) {
      global $post;
      $save_post = $post;
      $post = get_post($post_id);
      $output = get_the_excerpt();
      $post = $save_post;
      return $output;
    }
    
    <?php
    echo robins_get_the_excerpt('14'); ?>
  2. matthisco
    Member
    Posted 3 years ago #

    I'm trying this code now but it doesn;t work either, nothing shows up.

    <?php
    // retrieve one post with an ID of 5
    query_posts( 'p=2' );
    
    // set $more to 0 in order to only get the first part of the post
    global $more;
    $more = 0;
    
    // the Loop
    while (have_posts()) : the_post();
    echo the_content( 'Read the full post ยป' );
    endwhile;
    ?>

    Anyone?

Topic Closed

This topic has been closed to new replies.

About this Topic