How to sort custom content types alphabeticaly

  • Author
    Posts
  • #34002
    sandra

    I am using custom content types and site is listing them somehow (probably based on dates) but I would display them in alphabetical order. How to do that? I tried to add code I found from wordpress site but that messed up the design – it was displaying first alphabetical list with titles and after that non-alphabetical but beautiful list with titles and featured images. here is the code:

    <?php
    get_header();
    ?>
    
    <div id="content">
    <ul>
    <?php
    // we add this, to show all posts in our
    // Glossary sorted alphabetically
    if (is_category('Glossary')) 
    {
    $args = array( 'posts_per_page' => -1, 'orderby'=> 'title', 'order' => 'ASC' );
    $glossaryposts = get_posts( $args ); 
    }
    foreach( $glossaryposts as $post ) :	setup_postdata($post); 
     ?>
    <li><a>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
Viewing 1 post (of 1 total)

The topic ‘How to sort custom content types alphabeticaly’ is closed to new replies.