WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following setup: the front-page is setup as 'static' and it uses a theme page template. On this template / front-page, I need to get the page title, URL and excerpt of the About page.

I found this code that does exactly what I need, but I'm wandering if there's a different approach to this, one that would not use the page ID but the page slug or title.

    $page_id = 13;
    $page_data = get_page( $page_id );
    $the_excerpt = $page_data->post_excerpt;
    $title = $page_data->post_title;
<a href="<?php echo get_permalink(13); ?>">
    <?php echo $page_data->post_title; ?>

Later edit: Based on the answer provided by peteroak, this is the complete working code:

    $page = get_page_by_title( 'About' );
    $the_excerpt = $page->post_excerpt;
    $page_data = get_page( $page );
    $title = $page_data->post_title;
<header class="entry-header">
    <h1 class="entry-title">
        <a href="<?php echo esc_url( get_permalink( get_page_by_title( 'About' ) ) ); ?>">
            <?php echo $page_data->post_title; ?>
    <div class="entry-content"><?php echo $page->post_excerpt; ?>
        <a href="<?php echo esc_url( get_permalink( get_page_by_title( 'About' ) ) ); ?>">more +</a>
share|improve this question
hi found this trend code supply above is what i am looking for but I have no idea why the '<?php echo $page->post_excerpt; ?>' is not working!! can you tell me what i miss! thank's in advance – jhunlio Jul 12 '13 at 8:47
up vote 5 down vote accepted

the codex has exacly what you need: get_page_by_title()


 $page = get_page_by_title( 'About' );
 $the_excerpt = $page->post_excerpt;


 $page = get_page_by_path( 'parent-page/sub-page' );
share|improve this answer
i didn't knew that function exists. I made similar function a while ago. I guess i don't need that anymore :) – Sisir Jul 31 '12 at 11:31
Thanks for helping! I will update my post with the complete code that solves the problem. – George Grigorita Jul 31 '12 at 12:37
glad i could help :) – peteroak Jul 31 '12 at 13:04

Use the public API everywhere

Inside the loop, you can use get_the_excerpt() (without arguments). It's better than $post/$page->excerpt, as it also attaches the filters and checks if the page/post has a password.

share|improve this answer
I didn't used a loop for this, would it made any real difference - performance wise - if I use a loop with this code or not? – George Grigorita Jul 31 '12 at 12:44
In this case, you'd have to recreate the whole functions internals - see the link in the answer ↑ above. – kaiser Jul 31 '12 at 12:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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