PHP help (1 post)

  1. Kineta
    Posted 8 years ago #

    I'm a newbie w/ php. I found this nice bit of code that sorts categories into sections with the category as the header. I'd like to sort the posts alphabetically, but can't figure where to put the query_posts code.

    Here's what I have - bold text is what I added, but it doesn't do anything. if I use $myposts=query_post(etc) I get an alphabetical list, however it's all the entries, not just the relevant category

    <?php if($cats != NULL) { ?>
    		<?php foreach ($cats as $cat) { ?>
    			<?php if($cat != NULL) {
    				$base_url = get_bloginfo('home') . "/?cat=" . $cat->cat_ID; ?>
    				<h3><a href="<?php echo $base_url?>"><?php echo $cat->cat_name?></a></h3>
    			<?php } ?>
    			<?php // Show category description
    				if ($cat->category_description != NULL) ?>
    					<p><?php echo $cat->category_description ?></p>
    				<?php $myposts = get_posts("category=$cat->cat_ID"); ?>
    				<?php  query_posts($query_string . '&orderby=title&order=asc') ; foreach($myposts as $post) : ?>
    				<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    				<?php endforeach; ?>
    	<?php } ?>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.