/** * This file adds the category index to the Cultivate theme. * * @package Cultivate * @link http://restored316designs.com/themes * @author Lauren Gaige // Restored 316 LLC * @copyright Copyright (c) 2015, Restored 316 LLC, Released 10/19/2016 * @license GPL-2.0+ */ /* Template Name: Category Index */ add_action( 'genesis_meta', 'cultivate_category_genesis_meta' ); /** * Add widget support for category index. If no widgets active, display the default loop. * */ function cultivate_category_genesis_meta() { if ( is_active_sidebar( 'category-index' )) { remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'cultivate_category_sections' ); add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' ); } } function cultivate_category_sections() { genesis_widget_area( 'category-index', array( 'before' => '
', 'after' => '
', ) ); } //* Display as Columns add_filter( 'post_class', 'custom_grid_post_class' ); function custom_grid_post_class( $classes ) { if ( is_main_query() ) { // conditional to ensure that column classes do not apply to Featured widgets $columns = 2; // Set the number of columns here $column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' ); $classes[] = $column_classes[$columns]; global $wp_query; if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns ) $classes[] = 'first'; } return $classes; } genesis();