Forums

Query Children Of A Page Issue (13 posts)

  1. thisisedie
    Member
    Posted 2 weeks ago #

    I'm trying to query the children pages of a parent page. I have it set up so that the first post shown is the complete post and the other 9 are excerpts. The actual layout works perfectly using this:

    <?php query_posts('static=true&post_parent=4' . '&paged=' . $paged . '&showposts=10'); ?>

    but it doesn't stop at 10 (shows them all) and it doesn't paginate. It DOES stop at 10 and paginate if I use this setup to query POSTS in a category. Any help would be greatly appreciated :)

  2. MichaelH
    moderator
    Posted 2 weeks ago #

    This might work:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('post_type=page&post_parent=4' . '&paged=' . $paged . '&showposts=10');
    ?>
  3. t31os_
    Member
    Posted 2 weeks ago #

    Just a tip/note:

    You can't use paging when using showposts...
    If using paging, you should use posts_per_page ...

  4. MichaelH
    moderator
    Posted 2 weeks ago #

    Thanks--I've got to remember showposts is deprecated.

  5. t31os_
    Member
    Posted 2 weeks ago #

    I only realised that recently myself.. ;) ...

  6. thisisedie
    Member
    Posted 2 weeks ago #

    Thank you so much for your responses!

    Ok, if I use this:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('post_type=page&post_parent=4' . '&paged=' . $paged . '&posts_per_page=10');
    ?>

    no posts show up at all. I found out from my zillions of tests trying to figure this out that I can't use post_type=page -- I have to use static=true. Then the posts show up but there's still no pagination.

    Here's my code in it's entirety. Maybe I'm doing something wrong somewhere else?

  7. thisisedie
    Member
    Posted 2 weeks ago #

    PS: I decided to just show excerpts which is why I don't have it set up to show a full post and then excepts as I originally stated.

  8. t31os_
    Member
    Posted 2 weeks ago #

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("post_type=page&post_parent=4&paged=$paged&posts_per_page=10');
    ?>

    Works for me... assuming you want pages (not posts).

    Are you sure the parent ID is correct?

    How many pages are you expecting to get in the result?

  9. thisisedie
    Member
    Posted 2 weeks ago #

    I'm positive I have the right ID. With post_type=page I get a blank page. As soon as I change it to static=true the page excepts are there but don't paginate. What I'm doing is, writing a serial story. I have the main story page with a little description and then I have the parts listed as excerpts. Right now there are only 5 parts (I used 10 as an example). Eventully there will be many parts which I will break into 20 per page. Except they won't paginate, heh.

  10. t31os_
    Member
    Posted 2 weeks ago #

    Tested further, i can get paging links to show, but the paging doesn't work. Also sticky posts still seem to show up (bug i guess - caller_get_posts=1 fixes that).

    Though when i think about it, paging is (i think) intended for posts.

    I can't find a paging system for pages that exists, might need to check the plugins section.

  11. thisisedie
    Member
    Posted 2 weeks ago #

    Yeah I've tried everything and I don't think it's gonna work. Thanks for your time though :)

  12. t31os_
    Member
    Posted 2 weeks ago #

    Well paging should work, on the pages themselves, at least for paging of some kind, as the rewrite rules exist...

    However, creating lots of pages in this fashion will increase your rewrite rules by large amounts (a new rule is created for every page - pages are intended for static content), relying on category (or taxonomy) sorting would be far less intensive (posts use a more simple approach so don't fill up the rewrite list in the same way).

    Thought about using categories or taxonomies?

  13. thisisedie
    Member
    Posted 2 weeks ago #

    Yup I started out having them as posts and querying the category they were in which works perfectly. But I want the permalink to be sitename.com/mainstorypagewithexcerpts/partname/ and the blog posts to be date based. Since you can't have 2 different permalink structures, I was trying to do it this way.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.