Title: Formatting queries
Last modified: August 18, 2016

---

# Formatting queries

 *  [lazurus](https://wordpress.org/support/users/lazurus/)
 * (@lazurus)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/formatting-queries/)
 * Hi all,
 * I’m trying to display all posts alphabetically. I’ve managed to work something
   out, but can’t figure out how to get it formatted nicely.
 * `
    < ?php if (have_posts()) : while (have_posts()) : the_post(); the_title();
   endwhile; endif; query_posts('category_id=1&orderby=title&order=ASC&posts_per_page
   =-1'); if (have_posts()) : while (have_posts()) : the_post(); the_title(); endwhile;
   endif; ?>
 * I just want to break or li after each result, and have each result linked. Possible?
   Plausible? Too much like work?
 * Cheers!

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

 *  [skippy](https://wordpress.org/support/users/skippy/)
 * (@skippy)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/formatting-queries/#post-249106)
 * `<?php
    query_posts('category_id=1&orderby=title&order=ASC&posts_per_page=-1');
   if (have_posts()) : while (have_posts()) : the_post(); ?> <a href="<?php the_permalink();?
   >"><?php the_title(); ?></a><br /> <?php endwhile; endif; ?>
 * Note: completely untested.
 *  Thread Starter [lazurus](https://wordpress.org/support/users/lazurus/)
 * (@lazurus)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/formatting-queries/#post-249182)
 * Sweet… but…
 * `Parse error: parse error, unexpected $ in /home/music20/public_html/wp/wp-content/
   plugins/runphp.php(96) : eval()â€™d code on line 5`
 * All Reviews
 * Parse error: parse error, unexpected T_ENDWHILE in /home/music20/public_html/
   wp/wp-content/plugins/runphp.php(96) : eval()â€™d code on line 2
 * <b>A little more background…</b>
    Using the runphp plugin to toss this on a page.
   All Reviews is the page title.
 * Ta!
 *  [Beel](https://wordpress.org/support/users/beel/)
 * (@beel)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/formatting-queries/#post-249184)
 * The code looks good and should work. Create a page template for the All Reviews
   page and put it there.
 *  Thread Starter [lazurus](https://wordpress.org/support/users/lazurus/)
 * (@lazurus)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/formatting-queries/#post-249256)
 * Ah, I understand.
 * Okay, if anyone is searching for this, here is the solution, nicely packaged.
 * 1. Create a file on your local computer called single.php. Dump the following
   into that file:
    `<?php /* Template Name: Single Page */ ?>
 * <?php get_header(); ?>
    <?php get_sidebar(); ?>
 * <div id="content">
    <?php the_content(); ?> <?php query_posts('category_id=1&
   orderby=title&order=ASC&posts_per_page=-1'); if (have_posts()) : while (have_posts()):
   the_post(); ?> "><?php the_title(); ?> <?php endwhile; endif; ?> </div>
 * <?php get_footer(); ?>
 * Save the file and upload it to your themes dir in wp-content.
 * 2. Create a blank page (write –> pages). Set the template to be this page.
 * 3. Voila. It runs. Apply whatever formatting you want.
 * Thanks for the help **Beel** and **Skippy**.

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

The topic ‘Formatting queries’ is closed to new replies.

## Tags

 * [format](https://wordpress.org/support/topic-tag/format/)
 * [formatting](https://wordpress.org/support/topic-tag/formatting/)
 * [queries](https://wordpress.org/support/topic-tag/queries/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [lazurus](https://wordpress.org/support/users/lazurus/)
 * Last activity: [20 years, 9 months ago](https://wordpress.org/support/topic/formatting-queries/#post-249256)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
