PAGE excerpt in widget area? (4 posts)

  1. nicke.lundberg
    Posted 4 years ago #

    Hey guys!
    I've got a problem that I can't figure out...
    I've added the "add_post_type_support( 'page', 'excerpt' );" to my functions.php file in order to get the possibility to write excerpts for pages. That's working fine...

    However, I want to get the title, thumbnail and excerpt from a specific page to show up in a div/widget area on my homepage. So far I've got it working with the thumbnail and title, but I can't get the excerpt working..!

    I've tried all kinds of code after googleing. Here's how it curruntly looks:

    <?php echo get_the_post_thumbnail( $page_id = 5 ); ?>
    <?php echo get_the_title( $page_id = 5 ); ?>
    <?php echo the_excerpt( $page_id = 5 ); ?>

    Thanks in advance for any hints/tips!

  2. Andrei Olsen
    Posted 4 years ago #

        $page_id = 5;
        $page_data = get_page( $page_id );
        echo get_the_post_thumbnail( $page_id );
        echo $page_data->post_title;
        echo $page_data->post_excerpt;
  3. nicke.lundberg
    Posted 4 years ago #


    That gave me the thumbnail and the excerpt, but the post/page-title disappeared instead... Any idea why?

    Muchas gracis Andrei!

  4. Andrei Olsen
    Posted 4 years ago #

    Frankly, I don't know. It should work and it does work here. Weird.
    You could try get_the_title instead.

Topic Closed

This topic has been closed to new replies.

About this Topic