• Resolved thetooon

    (@thetooon)


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

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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.

    Thread Starter thetooon

    (@thetooon)

    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…

    Thread Starter thetooon

    (@thetooon)

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

    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
    
    endwhile;
    endif;

    Does that help?

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

    Thread Starter thetooon

    (@thetooon)

    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.

    See the information here regarding selecting just a column of data.
    http://codex.wordpress.org/Function_Reference/wpdb_Class#SELECT_a_Column
    and..
    http://codex.wordpress.org/Function_Reference/wpdb_Class#SELECT_Generic_Results

    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..).

    Thread Starter thetooon

    (@thetooon)

    Well, I used FlexiPages plugin finally.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘list of children as array’ is closed to new replies.