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 »

Alphabetize posts in a category


  #1  
Old Mar 22, 2009, 04:29 PM
paulae's Avatar
paulae
 
1,333 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
I want to have a category called Local Businesses, and I've used AZ-Index (wonderful plugin!) to create an index of categories of businesses, like Accountants, Clothing, Landscapers, etc. I made a text widget for the left sidebar using the index, only showing on the Business category. In addition, I pasted a list of accountants into a post called Accountants, another list into Clothing, etc.

Now, when you click on the Local Businesses link in the category menu, you are shown the most recent post, which is Dentists, because I put that in after Accountants. You can see it here: http://larchmontgazette.com/wp27/category/biz/

I found in the Wordpress codex (http://codex.wordpress.org/Alphabetizing_Posts) a way to alphabetize the output within a category, using a custom template. I created my-businesses-template.php, and put in their code (in red) thusly:

Code:
<?php
/*
Template Name Posts: My Businesses Template
*/
?>

<?php 
global $options; 
foreach ($options as $value) { 
	if (get_option( $value['id'] ) === FALSE) { 
		$$value['id'] = $value['std']; 
	} else { 
		$$value['id'] = get_option( $value['id'] ); 
	} 
}
if ( is_page() ) { global $wp_query; $current_page_id = $wp_query->get_queried_object_id(); }
?>
<?php get_header(); ?>
<?php // If there are any posts:
$posts = query_posts($query_string . 
'&orderby=title&order=asc&posts_per_page=-1');

if (have_posts()) : $postcount == 0; ?>
It's not working. Dentists is still showing up ahead of Clothing, Accountants, etc.

What am I doing wrong? Is it some difference between your index.php, which I used to make my-biz-template.php and the standard WP single post code?

Last edited by paulae; Mar 22, 2009 at 05:04 PM.
  #2  
Old Mar 23, 2009, 09:02 PM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
Change

PHP Code:
$posts query_posts($query_string 


to

PHP Code:
query_posts($query_string 
  #3  
Old Mar 23, 2009, 09:25 PM
paulae's Avatar
paulae
 
1,333 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
Alas, that didn't have any effect, I'm afraid. Dentists is still ahead of Accountants.

I'm supposed to leave out the $ at the beginning?

I also cleared the index cache, if that might have had something to do with it.

*EDIT* OK, I've gone back to the default template (index.php). After I made your change, Flynn, the Accountant, Dentists, Architects, etc., pages disappeared when clicked from the left archive menu. I must have messed up something in the code. Could you paste in the full modified code for index.php to be used as my-businesses-template.php to give me the alphabetized list of posts in the Businesses category? Sorry for being so dense!

Last edited by paulae; Mar 23, 2009 at 09:48 PM.
  #4  
Old Mar 23, 2009, 10:17 PM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
I had not seen that you're using this for a category page. Can you use a page (or post) template for a category? I am not sure. Normally you'd use category.php, or, in case of Atahualpa, and since it's only a small change, a conditional comment in index.php. Change in index.php

PHP Code:
<?php // If there are any posts:
if (have_posts()) : $postcount == 0?>
to
PHP Code:
<?php // If there are any posts:
if (is_category('Businesses')) {
     
$posts query_posts($query_string '&orderby=title&order=asc&posts_per_page=-1');

if (
have_posts()) : $postcount == 0?>
  #5  
Old Mar 24, 2009, 06:20 AM
paulae's Avatar
paulae
 
1,333 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
I'll try this. But yes, I've been using index.php modified as a category page, just renamed with the code at the top that you gave me to use it as a Page page. The word Posts has to be in that code. It was working fine, allowing me to have a banner ad in the body, for instance, that didn't appear on other category pages.

*EDIT* OK, I tried that. No change: http://larchmontgazette.com/wp27/category/biz/ . The posts are listed alphabetically, but in reverse order, I suppose because I posted them in that order. Of course, you usually want the most recent post to be at the top!

To be clear, I've taken the Businesses posts out of the custom template, so they're using index.php now. I've just posted a new one in Businesses, Landscapers. It was at the bottom of the page.

I was wondering about the time stamp. I had posted all of them yesterday, but set the publish date back to Jan. 22, to keep them from appearing on the front page as new posts. I just changed the posting time of day for Dentists, and sure enough, it is now below Landscapers. So the system is still using time instead of alphabet to list the posts in Businesses.

Sorry to be such a bother! I realize I'm asking for a lot more customization than most Atahualpa users probably need. Another payment is on the way. (I think "donation" is the wrong term here, since you are providing a professional service!)

Last edited by paulae; Mar 24, 2009 at 07:16 AM.
  #6  
Old Mar 24, 2009, 02:17 PM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
Quote:
Originally Posted by paulae
*EDIT* OK, I tried that. No change: http://larchmontgazette.com/wp27/category/biz/ . The posts are listed alphabetically, but in reverse order
Change order=asc to order=desc in the code
  #7  
Old Mar 24, 2009, 02:57 PM
paulae's Avatar
paulae
 
1,333 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
That didn't work either.

By the way, I need to stay out of there for a while. The server guys say there is something wrong with my installation, which is causing very slow loading. They say their other Wordpress customers' sites load much faster. I'm not surprised I did something wrong!

I will let you know what they find out.
  #8  
Old Apr 7, 2009, 02:48 PM
berryb
 
1 posts · Apr 2009
Hey paulae...

I did a search for alphabetizing posts and AZ-Index was what I was looking for, but thought I'd chime in on your problem.

I've got this working on my site... took some tweaking, but I eventually got it... http://www.rush.tv/category/athletes and its a category page. Hope this helps.

Code:
<?php $posts = query_posts( $query_string . '&orderby=title&order=asc' ); ?>
<?php if( $posts ) : ?>

		<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>

			<div class="cat-wrapper-athletes">
            
            	<?php if ( get_post_meta($post->ID, 'cat_thumb', true) ) { ?>
                
                <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php echo get_post_meta($post->ID, "cat_thumb", $single = true); ?>" width="290" height="100" alt="" class="main_cat_img" /></a><?php 
				
				} ?>
                
            	<div id="cat-info-athletes">
                
					<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                    <?php the_excerpt(); ?>
                    
				</div>
            
            </div>

		<?php endforeach; ?>
 
<?php endif; ?>
  #9  
Old Apr 7, 2009, 05:40 PM
paulae's Avatar
paulae
 
1,333 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
Hi there. Thanks for jumping in. Love the site, by the way. I'm an avid skier but stay on the safe side of extreme!

I confess I don't see where you have the names alphabetized at all. What am I missing?

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Category menu to show the category posts in the dropdown gjchandler Page & Category Menu Bars 5 Aug 16, 2009 05:42 AM
thumbnails for all category posts and searches veenublue Atahualpa 3 Wordpress theme 2 Apr 30, 2009 02:05 PM
Static pages with category posts? mcphoto Atahualpa 3 Wordpress theme 3 Apr 25, 2009 10:48 AM
Posts showing up twice on category pages? michiganbasketball Atahualpa 3 Wordpress theme 1 Mar 12, 2009 05:56 PM
abbreviated posts on category page matty5490 Excerpts, Read more, Pagination 2 Feb 5, 2009 09:24 AM


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


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