Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

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

Display posts alphabetically for one category, chronologically for other categories


  #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,768 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
  #4  
Old Jul 14, 2014, 05:34 PM
dherrenvt
 
6 posts · Aug 2013
I would like to do something related. When displaying a post within a particular category (in this case, my "grammar" category), I would like the Next and Previous Post links to display in alphabetical order by post title within just that category.

I found an old, closed, forum post about this topic and a plugin was suggested (WP Post Sorting plugin), but that hasn't been updated for over 2 years and doesn't appear to work with Wordpress 3.9.1 and Atahualpa 3.7.15.
  #5  
Old Jul 16, 2014, 09:01 AM
lmilesw's Avatar
lmilesw
 
10,174 posts · Jul 2009
Central New York State USA
Perhaps this plugin will work for you.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.

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 09:22 AM.


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