Last active
July 23, 2021 08:22
-
-
Save geoffreycrofte/d3b5c0ab64e97278248df59bc53082f0 to your computer and use it in GitHub Desktop.
Page Template to list all your categories with their title, description and RSS link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package WordPress | |
* @subpackage Creative Juiz v2 | |
* Template Name: Category List | |
* @see: https://gist.github.com/geoffreycrofte/d3b5c0ab64e97278248df59bc53082f0 | |
* @author: Geoffrey Crofte | |
*/ | |
get_header(); ?> | |
<main class="main-content" id="main-content"> | |
<div class="inside"> | |
<div class="part-main"> | |
<?php | |
juiz_breadcrumbs(); | |
if (have_posts()) : while (have_posts()) : the_post(); | |
?> | |
<div class="article block post-<?php the_ID(); ?> pt-page hentry" id="post-<?php the_ID(); ?>"> | |
<h1 class="article-title entry-title"><?php the_title() ?></h1> | |
<div class="separator"></div> | |
<div class="entry-content"> | |
<?php | |
the_content(); | |
endwhile; | |
endif; | |
// Get all the categories | |
$categories = get_categories(); | |
$cat_output = '<dl>'; | |
foreach ( $categories as $cat ) { | |
$cat_url = get_bloginfo('url') . '/theme/' . $cat->slug; | |
$cat_output .= ' | |
<dt> | |
<a href="'. $cat_url . '" title="' . __('Read articles of the category:', 'juiz') . ' "'. $cat->cat_name .'"">' . $cat->cat_name . '</a> | |
<span class="nb_articles">' . $cat -> category_count .' articles</span> | |
<a href="' . $cat_url . '/feed" title="' . __('Follow RSS feed of the category:', 'juiz') . ' "'. $cat->cat_name .'"" class="cat-rss"><i class="icon-feed"></i><span class="visually-hidden">RSS</span></a> | |
</dt> | |
<dd>' . $cat->category_description . '</dd> | |
'; | |
} | |
$cat_output .= '</dl>'; | |
echo $cat_output; | |
?> | |
</div><!-- .corps --> | |
</div><!-- .article.block --> | |
<?php | |
edit_post_link(__('Edit this page', 'juiz'), '<p>', '</p>'); | |
comments_template(); | |
?> | |
</div><!-- .part_main --> | |
</div><!-- .inside --> | |
</main><!-- .main_content --> | |
<?php get_sidebar(); ?> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment