<?php /** * The Template for displaying documents in an document category. Simply includes the archive taxonomies template. * * Override this template by copying it to yourtheme/documentate/taxonomy-docu_cat.php * * @author helgatheviking * @package Documentate/Templates * @version 0.1-beta */ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } documentate_get_template('archive-document.php');
/** * Display document sub categories as thumbnails. * * @subpackage Loop * @param array $args * @return null|boolean */ function documentate_document_subcategories($args = array()) { global $wp_query; $defaults = array('before' => '', 'after' => '', 'force_display' => false); $args = wp_parse_args($args, $defaults); extract($args); // Main query only if (!is_main_query() && !$force_display) { return; } // Don't show when, searching or when on page > 1 and ensure we're on an document archive if (is_search() || is_paged() || !is_document_category() && !is_document_archive()) { return; } // Check categories are enabled if (is_document_archive() && documentate_get_option('archive_display') == 'documents') { return; } // Find the category + category parent, if applicable $term = get_queried_object(); $parent_id = !empty($term->term_id) ? $term->term_id : 0; if (is_document_category()) { $display_type = get_term_meta($term->term_id, 'display_type', true); switch ($display_type) { case 'documents': return; break; case '': if (documentate_get_option('category_display') == 'documents') { return; } break; } } // NOTE: using child_of instead of parent - this is not ideal but due to a WP bug ( http://core.trac.wordpress.org/ticket/15626 ) pad_counts won't work $document_categories = get_categories(apply_filters('documentate_document_subcategories_args', array('parent' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => 'docu_cat', 'pad_counts' => 1))); if (!apply_filters('documentate_document_subcategories_hide_empty', false)) { $document_categories = wp_list_filter($document_categories, array('count' => 0), 'NOT'); } if ($document_categories) { echo $before; foreach ($document_categories as $category) { documentate_get_template('content-docu_cat.php', array('category' => $category)); } // If we are hiding documents disable the loop and pagination if (is_document_category()) { $display_type = get_term_meta($term->term_id, 'display_type', true); switch ($display_type) { case 'subcategories': $wp_query->post_count = 0; $wp_query->max_num_pages = 0; break; case '': if (documentate_get_option('category_display') == 'subcategories') { $wp_query->post_count = 0; $wp_query->max_num_pages = 0; } break; } } if (is_document_archive() && documentate_get_option('archive_display') == 'subcategories') { $wp_query->post_count = 0; $wp_query->max_num_pages = 0; } echo $after; return true; } }
<?php /** * documentate_after_document_loop hook * * @hooked documentate_pagination - 10 */ do_action('documentate_after_document_loop'); ?> <?php } elseif (!documentate_document_subcategories(array('before' => documentate_document_loop_start(false), 'after' => documentate_document_loop_end(false)))) { ?> <?php documentate_get_template('loop/no-documents-found.php'); ?> <?php } ?> <?php /** * documentate_after_main_content hook * * @hooked documentate_output_content_wrapper_end - 10 (outputs closing divs for the content) */ do_action('documentate_after_main_content'); ?>