Grow your CSS skills. Land your dream job.

How do I call title (and custom field info) from the newest subpage of a defined parent

  • # March 8, 2013 at 6:41 am

    Hi people,

    I am having great difficulty with a wordpress site. I am trying to call information from a page that is a sub-page to parent, and I was hoping someone would be able to help.

    Basically I have built a website that as well as the usual home, about and content page includes a shop that which has 3 levels of hierarchy.

    The store.
    – The categories. Sub-pages of the store.
    — The products. Sub-pages of the categories.

    Throughout the entire site I call a sidebar

    # March 8, 2013 at 12:19 pm

    Off the top of my head, I don’t think you can pull in pages based on date.

    # March 9, 2013 at 3:41 am

    I found this which displays the most recently created pages. This is the original code, but I have modified the one on my site to only display the title and image.

    However I do not know how to modify it so rather than showing the most recently created pages on the whole site, it only shows the most recently created child page of my design page.

    < ?php
    $args=array(
    ‘showposts’=>5,
    ‘post_type’ => ‘page’,
    ‘caller_get_posts’=>1
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>

    < ?php the_time('m.d.y') ?> ” rel=”bookmark” title=”Permanent Link to < ?php the_title_attribute(); ?>“>< ?php the_title(); ?>

    < ?php
    endwhile;
    }
    ?>

    Any help would be appreciated.

    # March 10, 2013 at 1:04 pm

    I have now got the answer to my question. For anyone who reads this and is struggling with the same thing then just add the following code to the initial argument.

    ‘post_parent’ => ’22’

    (replace 22 with the page id of the parent)

    The rest of the code stays the same. so it now becomes

    $args=array(
    ‘showposts’=>5,
    ‘post_type’ => ‘page’,
    ‘caller_get_posts’=>1,
    ‘post_parent’ => ’22’ //replace 22 with the page id of the parent.
    );

    Remember to add a , (comma) to the line before so the code knows ‘post_parent’ is a new argument.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".