WordPress.org

Ready to get started?Download WordPress

Forums

Ignore "The" In Alphabetical Archives (3 posts)

  1. FlashAmI
    Member
    Posted 9 months ago #

    Hi
    I have an archive page that lists all my posts in alphabetical order. Is there a way to make it ignore the "The" in posts names?

    <?php
    if(isset($wp_query->query_vars['category_name']))
    {
    	$cat = urldecode($wp_query->query_vars['category_name']);
    }
    query_posts('category_name='.$cat.'&showposts=-1&orderby=title&order=asc');
    ?>
    <a name="top"></a>
    <ul id="archive">
    <?php $count = 0; $newLetter = ''; ?>
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    	<?php
    	$count++;
    	$oldLetter = $newLetter;
    	$newLetter = substr(the_title('','',false), 0, 1);
    	if(strtolower($oldLetter) != strtolower($newLetter))
    	{
    		if($count != 1)
    			echo '<li class="entry-title" style="text-align:right"><a href="#top">Go To Top</a></li></ul></li>';
    		echo '<li><h2><a name="'.$newLetter.'"> </a>'.$newLetter.'</h2><ul>';
    	}
    	?>
    
    	<li class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
    	<?php endwhile; // end of the loop. ?>
    
    </ul>
  2. vtxyzzy
    Member
    Posted 9 months ago #

    You can use filters to modify the query. See this pastebin for some sample code: http://pastebin.com/X6bPHvSY

  3. FlashAmI
    Member
    Posted 8 months ago #

    thanks, i'll look into it. Some of its way over my head but hopefully I can figure it out.

Reply

You must log in to post.

About this Topic