WordPress.org

Ready to get started?Download WordPress

Forums

Sorting Posts Alphabetically (6 posts)

  1. sarcasteak
    Member
    Posted 4 years ago #

    Hi. I am attempting to sort my posts alphabetically under category, for example:

    http://www.bloodylexicon.com/category/monsters/

    I modified this line in the category.php for the template, but it doesn't seem to be working correctly. Any ideas?

    <?php wp_get_archives('type=monthly&format=link&orderby=title&order=asc'); ?>

  2. sarcasteak
    Member
    Posted 4 years ago #

    Hi, so I know I modified the wrong part. I am a programmer but php is not my expertise. Where/how are these methods included from? I don't see any include functions in my php that contain the method "single_cat_title", also, how does have_posts() know to only pull back ones of this category? The code that I am concerned about is here:

    <h3><?php single_cat_title(); ?></h3>
    
    <?php while(have_posts()) : the_post(); ?>
    <div class="excerpt">
    			<h2><a href="<?php echo get_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> </h2>
    
    						<div class="excerptentry"><?php the_excerpt(); ?><div class="excerptlink"><a href="<?php echo get_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> Click for more information...</a></div></div>
    
    		<div class="postmetadata">
    
    			<span class="date">Posted in <?php the_time('F jS, Y') ?></span>
    
    			<span class="comment"> <?php comments_popup_link('No Comments »','1 Comment »','% Comments »'); ?></span>
    
    			<span class="tag"><?php the_tags('Tags: ', ', ', ''); ?></span>
    
    		</div>
            <div class="clear"></div>
    </div>

    <?php endwhile; ?>`

  3. sarcasteak
    Member
    Posted 4 years ago #

    Okay, so I found the tutorial on wordpress's website, and I did not assume it was as easy as

    <?php
     $posts = query_posts($query_string .
    '&orderby=title&order=asc&posts_per_page=10');
    ?>

    How do I have access to change the $posts variable and it magically modifies the query?

  4. Tara
    Member
    Posted 4 years ago #

    Hi sarcasteak,

    <?php
    $posts = query_posts($query_string .
    '&orderby=title&order=asc&posts_per_page=10');
    ?>

    which file and where this code goes?
    I tried sidebar.php (default theme) and archives.php but it did not work.

    thanks.

  5. sarcasteak
    Member
    Posted 4 years ago #

    Hi, I placed this before "the loop" used to retrieve posts in my category.php

  6. Tara
    Member
    Posted 4 years ago #

    the default theme I use does not show any category.php, that's why I tried in archive.php and then in index.php. But No difference in results.

Topic Closed

This topic has been closed to new replies.

About this Topic