• Resolved aeneas07

    (@aeneas07)


    I can’t get the order parameter of query_posts to function properly

    Here was the original code:
    query_posts("showposts=$et_ptemplate_gallery_perpage&paged=" . $et_paged . $gallery_query);

    Here is the new query sorting by titles and ASC order:
    query_posts("showposts=$et_ptemplate_gallery_perpage&paged=" . "&orderby=title&order=ASC" . $et_paged . $gallery_query);

    It does sort by title, but not in ASC order

    I have run out of things to try.

    Here is a larger section of the code

    <?php $gallery_query = '';
    									$portfolio_count = 1;
    									$et_open_row = false;
    									if ( !empty($gallery_cats) ) $gallery_query = '&cat=' . implode(",", $gallery_cats);
    									else echo '<!-- gallery category is not selected -->'; ?>
    									<?php
    										$et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
    									?>
    									<?php query_posts("showposts=$et_ptemplate_gallery_perpage&paged=" . "&orderby=title&order=ASC" . $et_paged . $gallery_query); ?>
    									<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Thanks in advance for the help

Viewing 2 replies - 1 through 2 (of 2 total)
  • You’ve inserted the additional code in the wrong place.

    This is not tested but should work

    query_posts("orderby=title&order=ASC&showposts=$et_ptemplate_gallery_perpage&paged=". $et_paged . $gallery_query);

    You inserted it in between “paged=” and the value that paged is supposed to be set to, $et_paged So it was trying to set paged equal to "orderby=title" which is not a valid value for paged.

    Thread Starter aeneas07

    (@aeneas07)

    Thanks stvwlf! Does indeed work.
    I am an idiot

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘order ASC in query_posts() not working’ is closed to new replies.