Title: Really basic &quot;loop&quot; PHP question&#8230;
Last modified: August 20, 2016

---

# Really basic "loop" PHP question…

 *  [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/really-basic-loop-php-question-1/)
 * Here’s something that must be really easy, but I can’t understand the PHP needed
   to do it. I want to list all my posts (headline only) in chron order with the
   oldest first and a little header that identifies what number post it is…
 * Exactly like this:
    [http://www.matternetwork.com/paul-herman-hip-investor.cfm](http://www.matternetwork.com/paul-herman-hip-investor.cfm)
 * So I figure I’ll make a tag, call it “apples”, then make a custom tag pag called“
   tag-apples.php” ..
 * The hard part is how do i get it to go in reverse order and how can I add cleaver
   numbering to the posts?
 * Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/really-basic-loop-php-question-1/#post-2631666)
 * > I want to list all my posts (headline only) in chron order with the oldest 
   > first and a little header that identifies what number post it is…
 * > make a tag, call it “apples”, then make a custom tag pag called “tag-apples.
   > php” ..
 * – does that mean you want only all posts with the tag ‘apples’ in that list?
 * > get it to go in reverse order
 * [http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note](http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note)
 * – ideas to numbering:
    possibly with the use of a counter variable and for the
   output a function like this: [http://www.php.net/manual/en/function.number-format.php#89655](http://www.php.net/manual/en/function.number-format.php#89655)
 * you could use the [http://pastebin.com/](http://pastebin.com/) to share whatever
   code you have so far…
 *  Thread Starter [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/really-basic-loop-php-question-1/#post-2631821)
 * Bam, thanks a lot. I solved the number problem pretty simply… just used an ordered
   list!
 * But man, this php is killing me. It’s chicken or the egg on understanding how
   it works. That page you linked too shows all this “query_posts” stuff, but my
   code is much simpler, doesn’t have any of that. This is the only relevant part:
 *     ```
       <ol><?php while (have_posts()) : the_post(); ?>
       		<li><h4><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4></li>
       		<?php endwhile; ?>
       </ol>
       ```
   
 * Works great except for the order which I want to reverse….
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/really-basic-loop-php-question-1/#post-2631822)
 * following this link [http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note](http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note),
   insert the ‘query_posts’ stuff before the loop:
 *     ```
       <ol><?php global $query_string; query_posts($query_string . '&order=ASC'); while (have_posts()) : the_post(); ?>
       		<li><h4><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4></li>
       		<?php endwhile; ?>
       </ol>
       ```
   
 * it kind of says: use the existing query, but add the ‘order’ parameter and set
   it to ‘ASC’

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Really basic "loop" PHP question…’ is closed to new replies.

 * 3 replies
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/really-basic-loop-php-question-1/#post-2631822)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
