Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

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

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #43241
    SpartanCopy
    Member

    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

    #127493
    TheDoc
    Member

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

    #127575
    SpartanCopy
    Member

    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.

    $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(); ?>

    ” rel=”bookmark” title=”Permanent Link to “>

    endwhile;
    }
    ?>

    Any help would be appreciated.

    #127675
    SpartanCopy
    Member

    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)
  • The forum ‘Back End’ is closed to new topics and replies.