• 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)
  • <?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

    (@lazurus)

    Sweet… but…

    Parse error: parse error, unexpected $ in /home/music20/public_html/wp/wp-content/plugins/runphp.php(96) : eval()a€?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()a€?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!

    The code looks good and should work. Create a page template for the All Reviews page and put it there.

    Thread Starter lazurus

    (@lazurus)

    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.