I’m having a problem ordering some posts in a navigation list on a wordpress site. here is my (badly indented) code:
<ul class="tree lvl-0">
<?php
$args = array('child_of' => 6);
$categories = get_categories( $args );
foreach($categories as $category) {
echo '<li class="collapsed"><a href="' . get_category_link( $category->term_id ) . '"' . $category->name . '" ' . '>' . $category->name.'</a>';
$cat_id= $category->term_id;
wp_reset_query();
$args = array(
'cat' => $cat_id,
'posts_per_page' => 20,
'order' => 'ASC',
'orderby' => 'title'
);
query_posts($args);
// start the wordpress loop!
?>
<ul class="lvl-1">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
</ul>
</li>
<?php wp_reset_query(); } ?>
</ul>
the part in question is the
$args = array(
'cat' => $cat_id,
'posts_per_page' => 20,
'order' => 'ASC',
'orderby' => 'title'
);
query_posts($args);
Im not too sure what order they are in, It might be date.
Also, when I order by ‘name’ or anything else, it works. 🙁
Thanks for any help in advance
Problem is $args, do this:
You can also order by multiple parameters, like:
See Hobo’s comment on the question ^
My client is also using qTranslate, and it was the exact cause of the problem.