• Resolved Phillip

    (@phillustration)


    Hi everyone,

    New to wordpress so please excuse if I am making something simple very complicated.

    I am using wordpress to create a more traditional web site with navigation tabs: home, about, blog and contact.

    The home page is set as my static page. The about and contact pages are just set as standard page and the blog page contains my posts.

    I am trying to get the home page to display the titles and excerpts of the about and blog page on the home page. I have used the following code:

    <?php
    $page_id = 2;
    $page_data = get_page( $page_id );
    $content = $page_data->post_content;
    $title = $page_data->post_title;
    echo $page_data->post_content;
    ?>

    The page id of my contact page is 2. I have managed to get the excerpt of the page displaying but have had no luck with the title getting pulled through.

    Is this even possible? Thank you very much in advance.

    Phil Vale

Viewing 4 replies - 1 through 4 (of 4 total)
  • Looks like you need to add one more line to echo the title (you’ve retrieved it into the $title variable but you’re not echoing it).

    echo $page_data->post_title;

    Thread Starter Phillip

    (@phillustration)

    Fantastic! Thanks ambrosite.

    Works a treat! I wish I had thought to use the forum sooner….

    I’m quite new as well, today actually. How do you set pages as the static page and/or how do you create “home” pages and how do you edit them?

    Thread Starter Phillip

    (@phillustration)

    Hi Imcgowan,

    First time I have tried to help someone on this so bare with me.

    To set pages as a static page:

    1. Create the page that you want to have as a static page e.g. home
    2. Select Settings -> Reading
    a. Select the Static page option
    b. Choose the page that you want as your static page
    c. Choose the page that you want as your blog page

    Hope that helps. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get title and excerpt from page (about) and display on static page (home)’ is closed to new replies.