Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme »

Display posts alphabetically for one category, chronologically for other categories


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old Jun 6, 2009, 07:10 PM
spencer
 
5 posts · Jun 2009
I want to display the posts on most of my category pages in reverse chronological order, which is working just fine. But for one category (a glossary of terminology), I would like to display the posts in alphabetical order. I've created a separate category.php file for the glossary, but I can't get the order to change from the order in which I entered the posts. The page in question can be seen at:
http://www.jmek.net/bookbuildersWest...s/?page_id=199.

So far, I've been playing with the following php code in the template page. Is this the right place or should I be elsewhere? What do I need to change (here or elsewhere) to get the posts alphabetized?

if ( $bfa_ata_archives_category_show == "Yes" ) { ?>
<h3><?php echo $bfa_ata_archives_category_title; ?></h3>
<ul>
<?php wp_list_categories('orderby=name&order=asc&title_l i=' .
'&show_count=' . ($bfa_ata_archives_category_count == "Yes" ? '1' : '0') .
'&depth=' . $bfa_ata_archives_category_depth .
($bfa_ata_archives_category_feed == "Yes" ? '&feed_image=' . get_bloginfo('template_directory') . '/images/icons/feed.gif' : '')); ?>
</ul>
<?php } ?>

Spencer
  #2  
Old Jun 10, 2009, 05:42 AM
Flynn's Avatar
Flynn
 
3,730 posts · Oct 2008
Munich, Germany
wp_list_categories lists the list of categories, not the list of posts in a category: http://codex.wordpress.org/Template_...ist_categories

You can use get_posts for this: http://codex.wordpress.org/Template_Tags/get_posts

<ul>
<?php
global $post;
$myposts = get_posts('numberposts=10&order=ASC&orderby=title&category=1');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

replace category=1 with the ID of the category you want to pull posts from

To display this on a specific page, create a pagename.php, to display it on a specific category page create a category-ID.php

See http://codex.wordpress.org/File:Template_Hierarchy.png
  #3  
Old Nov 18, 2009, 04:21 AM
robdeluxe
 
2 posts · Oct 2009
Hi Flynn,

I am trying what you suggested but it is not working. Instead of returning posts for the current category it is returning all posts from all categories. Here is what I have tried...

<ul>
<?php
global $post;
if (is_category( )) {
$cat = get_query_var('cat');
$yourcat = get_category ($cat);
/*echo 'the slug is '. $yourcat->slug;*/

$myposts = get_posts('category=$cat&&numberposts=-1');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;
} ?>
</ul>

I am using wordpress v2.8.4. I think it might be a bug in get_posts?

Have you any ideas?

Thanks,
Rob

Bookmarks

Tags
alphabetize, category, organize

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing Uncategoried Category from the Display pkmittal81 Page & Category Menu Bars 2 Apr 16, 2010 07:06 PM
[SOLVED] category widget can not display inline in v3.4 duping812 New Versions, & Updating 5 Jul 11, 2009 11:10 AM
disable links in category menu for parent categories (only childless categories link) qcook2000 Page & Category Menu Bars 0 May 15, 2009 09:09 PM
Categories not showing any posts paulae Atahualpa 3 Wordpress theme 2 Mar 10, 2009 06:35 AM
RIGHT sidebar: Don't display on Categories: Not working Ponics Atahualpa 3 Wordpress theme 6 Dec 27, 2008 06:47 AM


All times are GMT -6. The time now is 10:13 AM.


Powered by vBulletin® Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.