WordPress.org

Ready to get started?Download WordPress

Forums

Query Pages and post excerpts dynamically (1 post)

  1. bucthree
    Member
    Posted 12 months ago #

    So I'm new to WordPress, and Im creating a custom theme. I have a custom home page, a blog page which includes a dynamic preview area of the latest 5 blogs, and some other miscellaneous pages. Im trying to design an "events" page where the main page has a sidebar that looks like this:
    http://imgur.com/ezEIApD

    You can then click on each section, which will open up and have a brief description of the event taken from the page with a read more link to go to that page.

    http://imgur.com/Gz9RDYx

    So I have a parent page called "Events Main" and then I have some test pages set up as child pages of the "Events Main" page.

    Im a complete beginner at PHP and I was wondering how I could go about querying child pages to fill in that content dynamically.

    Im currently using this code `<?php
    $page_id = 85;
    $page_data = get_page( $page_id );
    $content = $page_data->post_excerpt;
    $title = $page_data->post_title;
    echo $page_data->post_title;
    echo $page_data->post_excerpt;
    ?>`
    but I have to go in and fill the page id number for each section. I need it to automatically populate these fields, so whenever a new child page is added it will show up.

    Any suggestions?

Reply

You must log in to post.

About this Topic