WordPress.org

Ready to get started?Download WordPress

Forums

Ascending Code Not Working in My Template (3 posts)

  1. yakutistan
    Member
    Posted 5 years ago #

    I have created a template page that lists all post titles in a specific category.

    My page code works great but I couldn't reorder it in date-ascending order.

    I changed this:

    <?php if (have_posts()) : ?>

    to

    <?php
    query_posts($query_string . '&order=ASC');
    if (have_posts()) : ?>

    But it didnt work.

    My template code is here:

    <div id="content" class="section">
    
    <?php
    // page id 714 will get category ID 11 posts, page 718 will get category 3 posts
    if (is_page('714') ) {
    $cat = array(11);
    } elseif ( is_page('718') ) {
    $cat = array(3);
    } elseif ( is_page('28') ) {
    $cat = array(17);
    } else {
    $cat = '';
    }
    
    $showposts = -1; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
       'category__in' => $cat,
       'showposts' => $showposts,
       'caller_get_posts' => $do_not_show_stickies
       );
    $my_query = new WP_Query($args);
    ?>
    
    	<?php if( $my_query->have_posts() ) : ?>
    		<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h4><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
    
    </div>
  2. esmi
    Forum Moderator
    Posted 5 years ago #

    Try adding orderby=date?

  3. yakutistan
    Member
    Posted 5 years ago #

    where sould i add "orderby=date", before/after which phrase or tag?

Topic Closed

This topic has been closed to new replies.

About this Topic