WordPress.org

Ready to get started?Download WordPress

Forums

Getting custom posts to display alphabetically (1 post)

  1. Jack Barham
    Member
    Posted 2 years ago #

    Hello, I am using custom post types and I am pulling the title of each post type to a specific landing page (each title is a link to that custom post page).

    However, I would like the list to display alphabetically (not by date which it is currently set by).

    This is the code I am currently using:

    <ul class="sidenav1">
    <?php $loop = new WP_Query( array( 'post_type' => 'locations') ); ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <li><?php the_title( '<a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a>'); ?></li>
    <?php endwhile; ?>
    </ul>

    Any help would be appreciated - Thanks.

    Jack

Topic Closed

This topic has been closed to new replies.

About this Topic