This is the documentation for LemonStand V1, which has been discontinued. You can learn more and upgrade your store here.

LemonStand Version 1 Has Been Discontinued

This documentation is for LemonStand Version 1. LemonStand is now offered as a cloud-based eCommerce platform.
You can try the new LemonStand and learn about upgrading here.

Displaying a blog category list

There is no special action for displaying a list of blog category pages. To display the category list, you need to use the API, and specifically the Blog_Category class. Below is a code example, which outputs a list of categories with a number of blog posts belonging to each of them. In the code example we assume that the blog category page has the "/blog/category" URL.

<ul>
  <?
      $categories = Blog_Category::create()->find_all();
      foreach ($categories as $category):
  ?>
      <li>
        <a href="/blog/category/<?= $category->url_name ?>">
        <?= $category->name ?> (<?= $category->published_post_num ?>)
      </a>
      </li>
  <? endforeach ?>
</ul>

Example of the category list:

Next: Category page
Previous: Implementing the blog archive page
Return to Blog module