Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

index showing a-z instead of previous + 3 columns underneath WordPress

  • SOLVED

I am using AZIndex which loads all posts under a category in an unordered list. What I need is an alphabetical index a,b,c,d,e,f,... z followed by three columns with post title, translation (custom field) and date. Each letter will be connected to the post title which will represent a word. Basically I want to mimic: http://www.business-spotlight.de/language-skills/word-of-the-day. How to handle this?

I know WordPress has template tags for showing previous and next posts: http://codex.wordpress.org/Next_and_Previous_Links#The_Next_and_Previous_Posts . But I need to have a alphabet list with each alphabet leading to all words starting with that latter, followed by translation - custom field and publication date.

Answers (2)

2011-08-22

Pixel Coder answers:

This sounds a little unique in functionality and whilst plugins are great if you want to use it as is, you definitely need to able to add what you need.

Had a customer recently from here on WPQuestions who had a similar criteria. If you can up your donation a little bit so we can benefit from time spent on this i'll be happy to implement. It's about 1 hour of work.


Pixel Coder comments:

If you would like to send a private message with your site details Jasper I'll get on this now.


rhand comments:

Sent details.


Pixel Coder comments:

Hi Jasper,

Here's a rough indication on how to implement this.

Unable to get you today.


<?php
/*
Template name: Page: A to Z
*/
?>

<?php get_header() ?>

<div class="page-desc">
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>

<?php $px_cat_id = get_post_meta($post->ID, 'px_category', true); ?>
<?php the_content() ?>

<?php endwhile; else : ?>

<p>No content for this page yet.</p>

<?php endif; ?>
</div>
<!-- END PAGE -->
<ul class="px-letter-list">

<?php $px_letters = array('a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z'); ?>

<?php foreach($px_letters as $px_letter) : ?>

<li><a href="#az-<?php echo $px_letter; ?>" title="Go to the letter A"><?php echo $px_letter; ?></a></li>

<?php endforeach; ?>

</ul>
<!-- END AZ LINKS -->
<div class="px-az-wrap">
<?php
$px_args = array('showposts' => -1,
'cat' => $px_cat_id,
'orderby' => 'title',
'order' => 'asc',
'paged' => $paged);
?>
<?php query_posts($px_args); ?>
<?php
if(have_posts()) : while(have_posts()) : the_post();
$px_translation = get_post_meta($post->ID, 'px_translation', true);
$px_this_letter = strtoupper(substr($post->post_title, 0, 1));
?>

<div class="px-item">
<div class="column">
<a href="<?php the_permalink() ?>"><?php the_title() ?></a>
</div>
<div class="column">
<?php echo $px_translation; ?>
</div>
<div class="column">
<?php the_time('d M Y'); ?>
</div>


<?php if($px_this_letter != $px_last_letter) : ?>
<?php $px_last_letter = $px_this_letter; ?>
<?php // Does not have to be visible ?>
<?php // Only an ID for reference ?>
<h2><a href="#az-top" id="az-<?php echo strtolower($px_last_letter); ?>"><?php echo $px_last_letter; ?></a></h2>
<?php endif; ?>

</div>
<!-- END ITEM -->

<?php endwhile; else : ?>

<p>No items here yet.</p>

<?php endif; ?>

</div>
<!-- END PX AZ WRAP -->

<?php get_sidebar(); ?>

<?php get_footer() ?>


For this to work you need a custom field called "px_category"

You create a page where you want the A to Z list appear.

You place the ID (numeric value) of the category in forementioned custom field on the page.

Assign this template to that page.

Make sure you have a custom field called "px_translation".

Use this when creating a post.

Place the post under the category used on the page.

There you have it.

2011-08-22

Svilen Popov answers:

query_posts('orderby=title&order=ASC' );

or

[[LINK href="http://wordpress.org/extend/plugins/wp-post-sorting/"]]WP Post Sorting[[/LINK]]