[resolved] list of children as array (8 posts)

  1. thetooon
    Posted 6 years ago #

    Is there any way to return as array all children of the parent page?

    get_children _list doesn't seem to work in such way.

    Should I hack into wp_query()?

  2. Mark / t31os

    Posted 6 years ago #

    Can you be more specific, what are you trying to get, and in what context?..

    Alot of functions return items as an array or an object, and sometimes that's optional, depending on the function.

    Can you give me a usage example, and i'll try to offer an alternative to what you've tried.

  3. thetooon
    Posted 6 years ago #

    According to Page & Post parameters the following code suppose to return something with children:

    $allsearch = &new WP_Query("post_parent=3&showposts=-1");
    echo '<pre>'; var_dump($allsearch); echo '</pre>';

    but it doesn't...

  4. thetooon
    Posted 6 years ago #

    I'm trying to get childre list of specific page as array, that's it.

  5. Mark / t31os

    Posted 6 years ago #

    WP_Query is an object, to see the results you need to call the necessary methods of the WP_Query class, like you'd see with a regular loop.. to iterate over the results ..

    if( $allsearch->have_posts() ) :
    while( $allsearch->have_posts() ) : $allsearch->the_post()
    // STUFF

    Does that help?

    Suggestion, if this isn't suited, take a look at get_posts()

  6. thetooon
    Posted 6 years ago #

    Doesn't help at all.

    I need simple call to get the list of children's IDs as ARRAY.

    Don't need pages themself.
    Don't need complicated hacks.
    Don't need invent a wheel.

    Need bloody array with ids. Nothing else.

  7. Mark / t31os

    Posted 6 years ago #

    See the information here regarding selecting just a column of data.

    I generally use the get_col method when i'm selecting just post ids as this is obviously more efficient than a query consisting of unneeded post data (content, title, etc..).

  8. thetooon
    Posted 6 years ago #

    Well, I used FlexiPages plugin finally.

Topic Closed

This topic has been closed to new replies.

About this Topic