Last active
January 10, 2018 01:38
-
-
Save CNick/89d5b78b5fab91309def89ecdbf66db7 to your computer and use it in GitHub Desktop.
Custom category.php file for DSWI ADS site. Wireframe can be viewed here: http://cnickerson.com/wireframe/category-wireframe.png
This file contains 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 | |
/** | |
* The archive template file. | |
* | |
* WARNING: This template file is a core part of the | |
* Theme Blvd WordPress Framework. It is advised | |
* that any edits to the way this file displays its | |
* content be done with via hooks, filters, and | |
* template parts. | |
* | |
* @author Jason Bobich | |
* @copyright Copyright (c) Jason Bobich | |
* @link http://jasonbobich.com | |
* @link http://themeblvd.com | |
* @package Theme Blvd WordPress Framework | |
*/ | |
get_header(); | |
?> | |
<div id="sidebar_layout" class="clearfix"> | |
<div class="sidebar_layout-inner"> | |
<div class="row grid-protection"> | |
<?php get_sidebar( 'left' ); ?> | |
<!-- CONTENT (start) --> | |
<div id="content" class="<?php echo themeblvd_get_column_class('content'); ?> clearfix" role="main"> | |
<div class="inner"> | |
<?php themeblvd_content_top(); ?> | |
<div class="cat-block"> | |
<h1 class="entry-title"><?php single_cat_title(); ?></h1> | |
<?php if ( category_description() ) : // Show an optional category description ?> | |
<div class="archive-meta clearfix"> | |
<?php echo category_description(); ?> | |
</div> | |
<?php endif; ?> | |
<h2><?php single_cat_title(); ?> Articles</h2> | |
<!-- Start the current category post list --> | |
<div class="post_list post_list_paginated archive"> | |
<?php | |
$args = array( | |
'category' => get_queried_object_id(), // Current category id | |
'category__in' => array( get_queried_object_id() ), // Only posts that are direct children of the current category | |
'orderby' => 'post_date', | |
'order' => 'DESC', | |
); | |
$cat_posts = get_posts( $args ); | |
if($cat_posts) : | |
echo '<ul class="topics-ul fa-ul">'; | |
foreach($cat_posts as $post) : setup_postdata($post); ?> | |
<li class="topics-li"><i class="fa-li fa fa-check"></i><a href="<?php the_permalink();?>"><?php customTitle(34) // custom length for title ?></a></li> | |
<?php endforeach; // foreach($cat_posts) | |
echo '</ul>'; | |
endif; // if($cat_posts) | |
?> | |
</div><!-- .post_list --> | |
<!-- End the current category post list --> | |
</div><!-- .cat-block --> | |
<!-- Show More Topics and output grid of subcategories if current category has children --> | |
<?php | |
$term = get_queried_object(); | |
$children = get_terms( $term->taxonomy, array( | |
'parent' => $term->term_id, | |
'hide_empty' => false | |
) ); | |
if($children) { // get_terms will return false if tax does not exist or term wasn't found. | |
?> | |
<div class="subcat-wrap"> | |
<div class="row"> | |
<div class="col-xs-12"> | |
<h2>More <?php single_cat_title(); ?> Topics</h2> | |
</div> | |
<div class="subcat-grid"> | |
<?php $this_category = get_category($cat); ?> | |
<?php | |
$id = get_query_var('cat'); | |
$args = array( 'parent' => $id ); | |
foreach (get_categories($args) as $cat) : ?> | |
<div class="col-sm-6"> | |
<!-- Header for the categories --> | |
<div class="row"><!-- nested row --> | |
<div class="col-xs-9 col-sm-8"> | |
<h2><a href="<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->cat_name; ?></a></h2> | |
<!-- List 4 posts from each subcategory --> | |
<?php $cat_id= $cat->term_id; | |
$args = array( 'cat' => $cat_id, 'posts_per_page' => 4 ); | |
$posts = get_posts($args); | |
if($posts) : | |
echo "<ul>"; | |
foreach($posts as $post) : setup_postdata($post); ?> | |
<li><a href="<?php the_permalink();?>"><?php customTitle(34) // custom length for title ?></a></li> | |
<?php endforeach; // foreach($posts) | |
echo "</ul>"; | |
endif; // if($posts) ?> | |
</div><!-- .col --> | |
<div class="col-xs-3 col-sm-4"> | |
<!-- Category image --> | |
<?php if (function_exists('z_taxonomy_image_url')) { ?> | |
<a href="<?php echo get_category_link($cat->term_id); ?>"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /></a> | |
<?php | |
} | |
?> | |
<!-- End Category image --> | |
</div><!-- .col --> | |
</div><!-- .row - nested row--> | |
<div class="row"> | |
<!-- All Topics Link --> | |
<div class="col-xs-12"> | |
<p class="more-link"> | |
<i class="fa fa-angle-double-right"></i> | |
<a href="<?php echo get_category_link($cat->term_id); ?>">All <?php echo $cat->cat_name; ?> Topics</a> | |
</p> | |
</div><!-- .col --> | |
</div><!-- .row --> | |
</div><!-- .col --> | |
<?php endforeach; ?> | |
</div><!-- .subcat-grid --> | |
</div> <!-- .row --> | |
</div><!-- .subcat-wrap--> | |
<!-- end the subcategories --> | |
<?php | |
}// if($children) | |
?> | |
<?php themeblvd_content_bottom(); ?> | |
</div><!-- .inner (end) --> | |
</div><!-- #content (end) --> | |
<!-- CONTENT (end) --> | |
<?php get_sidebar( 'right' ); ?> | |
</div><!-- .grid-protection (end) --> | |
</div><!-- .sidebar_layout-inner (end) --> | |
</div><!-- #sidebar_layout (end) --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment