Toni Joe
Toni Joe

Reputation: 8417

List categories alphabetically in wordpress

Is there any way to list all categories in WordPress in a dictionary fashion:

A

cat.

cat.

cat.

B

cat.

cat.

cat.

C

cat.

cat.

cat.

...and so on

I thank you in advance

Upvotes: 1

Views: 2256

Answers (2)

Alex
Alex

Reputation: 132

Well, if you don't know php and want a plugin for it, this simple one here should work to alphabetize categories, posts and pages: https://wordpress.org/plugins/wp-alphabetical-post-listing/ though I have not tried it myself, so let me know if it works.

Upvotes: 0

Alex
Alex

Reputation: 132

if you know some php you can modify or create a category.php page in your themes main directory. Then simply add the following lines to make it alphabetical:

<?php
get_header();
?>

<div id="content">
<ul>
<?php
// we add this, to show all posts in our
// Glossary sorted alphabetically
if (is_category('Glossary')) 
{
$args = array( 'posts_per_page' => -1, 'orderby'=> 'title', 'order' => 'ASC' );
$glossaryposts = get_posts( $args ); 
}
foreach( $glossaryposts as $post ) :	setup_postdata($post); 
 ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

Upvotes: 1

Related Questions