Need Help With WP_Query (sort order)
-
I keep killing my site when trying to modify the arguments in a WP_Query
If I try to add a sort order such as:
'orderby' => 'title'To the arguments, then the site crashes.
Here is how I am passing the arguments:
$args = array( 'post_parent' => $post->ID, 'post_type' => 'page' 'orderby' => 'title' ); $subpages = new WP_query($args);But if I leave it OUT of the arguments, then It won’t crash. For example, it works fine if I just do this:
$args = array( 'post_parent' => $post->ID, 'post_type' => 'page' ); $subpages = new WP_query($args);But once I add ‘orderby’ => ‘title’, the site and the admin crash (just a white screen, no source is output to the screen at all).
And yes, I am trying to return pages, not posts.
I really am not sure what is going wrong.
If it helps, I am trying to use this whole bit of code for displaying child pages and their descriptions. The entire bit of code is:
function subpage_peek() { global $post; //query subpages $args = array( 'post_parent' => $post->ID, 'post_type' => 'page' ); $subpages = new WP_query($args); // create output if ($subpages->have_posts()) : $output = '<ul>'; while ($subpages->have_posts()) : $subpages->the_post(); $output .= '<li><strong><a href="'.get_permalink().'">'.get_the_title().'</a></strong> <p>'.get_the_excerpt().'<br /> <a href="'.get_permalink().'">Continue Reading ?</a></p></li>'; endwhile; $output .= '</ul>'; else : $output = '<p>No subpages found.</p>'; endif; // reset the query wp_reset_postdata(); // return something return $output; } add_shortcode('subpage_peek', 'subpage_peek'); // displays category descriptions as well as names - call with desc_cats() function desc_cats(){ foreach (get_categories(array('hide_empty'=>true)) as $category) { $catid = $category->cat_ID; echo '<li><a href="' . get_bloginfo('wpurl') . '/' . $category->category_nicename . '/">' . $category->cat_name . ' (' . $category->count.$numposts.')</a>' . category_description($catid) . '</li>'; } echo'<p>'; // puts a paragraph tag after last category description listed };
The topic ‘Need Help With WP_Query (sort order)’ is closed to new replies.