• Resolved EntarteteMuzak

    (@entartetemuzak)


    I want to order my posts in a category (without specifying the category in the script) ascending by title. So far no luck. I rifled through this and this.

    Here is my code:

    <?php if (have_posts()) : ?>
    
     	  <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
     	  <?php /* If this is a category archive */ if (is_category()) { ?>
    		<h2 class="pagetitle"><?php single_cat_title(); ?></h2>
     	  <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    		<h2 class="pagetitle">‘<?php single_tag_title(); ?>’</h2>
     	  <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    		<h2 class="pagetitle"><?php the_time('F jS, Y'); ?></h2>
     	  <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    		<h2 class="pagetitle"><?php the_time('F, Y'); ?></h2>
     	  <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    		<h2 class="pagetitle"><?php the_time('Y'); ?></h2>
    	  <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    		<h2 class="pagetitle">Author Archive</h2>
     	  <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    		<h2 class="pagetitle">Blog Archives</h2>
    
    <?php } ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <h3 id="post-<?php the_ID(); ?>" class="articletitle"><?php the_title(); ?></h3>
    
    				<div class="entry">
    					<?php the_content() ?>
    				</div>
    
    				<?php edit_post_link('Edit', '<div class="edit">', '</div>'); ?>
    
    		<?php endwhile; ?>
    
    <br /><br />
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Newer') ?></div>
    			<div class="alignright"><?php previous_posts_link('Older &raquo;') ?></div>
    		</div>
    
    	<?php else :
    
    		if ( is_category() ) { // If this is a category archive
    			printf("<h2 class='center'>Category ‘ %s ’ is empty</h2><br /><br />", single_cat_title('',false));
    		} else if ( is_date() ) { // If this is a date archive
    			echo("<h2>No posts match your query</h2>");
    		} else if ( is_author() ) { // If this is a category archive
    			$userdata = get_userdatabylogin(get_query_var('author_name'));
    			printf("<h2 class='center'>No posts match your query</h2>", $userdata->display_name);
    		} else {
    			echo("<h2 class='center'>No posts match your query.</h2>");
    		}
    
    	endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Order post by title’ is closed to new replies.