WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] get_children => sort_order not working (3 posts)

  1. chriseverson
    Member
    Posted 3 years ago #

    I'm having trouble convincing a get_children query to order.

    I'm using the code below to pull children of the current page two at a time.

    for ($i = 0; $i < 10; $i++,$i++) { // iterate through by two
    		$args = array ('post_parent'=>get_the_ID(),'post_status'=>'publish','numberposts'=>2,'offset'=>$i,'sort_order'=>'ASC'); // Build the query
    		$prods = get_children($args);
    		if(empty($prods)) continue; // Exit loop

    Everything is working perfectly with the one exception of sort_order. I've tried putting it in every position in the array and still nothing changes when I do ASC or DESC as the value.

    Any ideas? I feel like I'm just missing something obvious and need an extra set of eyes.

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    i could not find 'sort_order' as a parameter of get_posts() or query_posts()

    try

    'order' => 'DESC'

  3. chriseverson
    Member
    Posted 3 years ago #

    Wow. Thanks! I knew it was something stupid that I just overlooked.

Topic Closed

This topic has been closed to new replies.

About this Topic