Created
May 15, 2019 13:08
-
-
Save westcoastdigital/612632d1fcf1da9d60e2f7bc639af7cf to your computer and use it in GitHub Desktop.
Create a page template to display categories
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 | |
| /* Template Name: Category Template */ | |
| if ( ! defined( 'ABSPATH' ) ) { | |
| exit; // Exit if accessed directly. | |
| } | |
| get_header(); ?> | |
| <div id="primary" <?php generate_do_element_classes( 'content' ); ?>> | |
| <main id="main" <?php generate_do_element_classes( 'main' ); ?>> | |
| <?php | |
| /** | |
| * generate_before_main_content hook. | |
| * | |
| * @since 0.1 | |
| */ | |
| do_action( 'generate_before_main_content' ); | |
| $categories = get_categories(); | |
| foreach ( $categories as $cat ) { ?> | |
| <?php do_action( 'generate_before_term' ); ?> | |
| <div class="category" id ="category-<?php echo $cat->term_id; ?>"> | |
| <a class="cat-link" href="<?php echo get_category_link( $cat->term_id ); ?>"> | |
| <?php do_action( 'generate_before_term_title' ); ?> | |
| <h2 class="cat-title"><?php echo $cat->name; ?></h2> | |
| <?php do_action( 'generate_before_term_desc' ); ?> | |
| <p class="cat-description"><?php echo $cat->description; ?></p> | |
| <?php do_action( 'generate_after_term_desc' ); ?> | |
| </a> | |
| </div> | |
| <?php do_action( 'generate_after_term' ); ?> | |
| <?php } | |
| /** | |
| * generate_after_main_content hook. | |
| * | |
| * @since 0.1 | |
| */ | |
| do_action( 'generate_after_main_content' ); | |
| ?> | |
| </main><!-- #main --> | |
| </div><!-- #primary --> | |
| <?php | |
| /** | |
| * generate_after_primary_content_area hook. | |
| * | |
| * @since 2.0 | |
| */ | |
| do_action( 'generate_after_primary_content_area' ); | |
| generate_construct_sidebars(); | |
| get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment