0

Is it possible in wordpress when I call example.com/category to have listed all available categories. If I request the url like in my example I'm getting an 404 page

1
  • wordpress.stackexchange.com is the place you're looking for - and don't forget to search first for a similar question before asking :-) Commented Sep 13, 2012 at 8:41

1 Answer 1

1

I'm not sure if there is a default link to list all the categories.

But it doesn't mean you can't do it yourself. Create a new template file in your theme, name it for example category_list.php and add this code:

You might want to tweak it a bit to display it how you want.

<?php
/**
 * Template Name: Category listing
 * Description: list all the categories
 */

get_header(); ?>

    <div class="container">
        <?php
        $args=array(
            'orderby' => 'name',
            'order' => 'ASC'
        );
        $categories=get_categories($args);
        foreach($categories as $category):
            echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
            echo '<p> Description:'. $category->description . '</p>';
            echo '<p> Post Count: '. $category->count . '</p>';  
            echo '<hr />'; 
        endforeach;
        ?>
    </div>

<?php get_footer(); ?>

Then go to Pages -> add new. Name the Page as "Category", so that the url will be example.com/category.

And in the template list select the template you just created. It will be named "Category listing" as you can see in the code above in the comments at the top.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.