0

I've a custom/static "homepage.php" in my templates directory at my WordPress. Now I need to show differents "page excerpts" in my homepage, but I don't know what should be do it.

At this moment I've in my "functions.php" de following function:

function excerpt_page() {
  add_post_type_support( 'page', 'excerpt' );
}
add_action('init', 'excerpt_page');

With this function, I've in my Page editor a new field available where I can put an summary of the page.

Somebody has any idea?

2 Answers 2

0

Not sure if this is what you looking for... To display excerpt of specific page, you can use this code:

<?php
    $post_id = 2; // substitute to your page id
    $my_post = get_post($post_id);
    echo "<p>$my_post->post_excerpt</p>";
    echo '<a href="'.get_permalink( $post_id ).'">read more</a>';
?>
0
0

Thank you very much!

Finally, I've succeeded with the following code :D

<?php
$pages = get_pages('include=10,20,30,40,50,60');
foreach ($pages as $page) {
  $featured_content = '<div class="four columns">'.
                        '<h4><a href="'. get_page_link($page->ID) .'" title="'. $page->post_title .'">'. $page->post_title .'</a></h4>' .
                        '<p>'. $page->post_excerpt .'</p>' .
                      '</div>';
  echo $featured_content;
};
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.