/** * Basic top-level template hierarchy. I generally prefer to leave this functionality up to * themes. This is just a foundation to build upon if needed. * * @since 1.0.0 * @access public * @param string $template * @return string */ function ccp_template_include($template) { // Bail if not a portfolio page. if (!ccp_is_portfolio()) { return $template; } $templates = array(); // Author archive. if (ccp_is_author()) { $templates[] = 'portfolio-author.php'; $templates[] = 'portfolio-archive.php'; // Category archive. } else { if (ccp_is_category()) { $templates[] = 'portfolio-category.php'; $templates[] = 'portfolio-archive.php'; // Tag archive. } else { if (ccp_is_tag()) { $templates[] = 'portfolio-tag.php'; $templates[] = 'portfolio-archive.php'; // Project archive. } else { if (ccp_is_project_archive()) { $templates[] = 'portfolio-archive.php'; // Single project. } else { if (ccp_is_single_project()) { $templates[] = 'portfolio-project.php'; } } } } } // Fallback template. $templates[] = 'portfolio.php'; // Check if we have a template. $has_template = locate_template(apply_filters('ccp_template_hierarchy', $templates)); // Return the template. return $has_template ? $has_template : $template; }
/** * Conditional tag to check if viewing any portfolio page. * * @since 1.0.0 * @access public * @param mixed $term * @return bool */ function ccp_is_portfolio() { $is_portfolio = ccp_is_project_archive() || ccp_is_single_project() || ccp_is_author() || ccp_is_category() || ccp_is_tag(); return apply_filters('ccp_is_portfolio', $is_portfolio); }