コード例 #1
0
/**
 * Expands the body classes added by WordPress. <br />
 * Only called by `add_filter('body_class','pp_body_classes');`
 *
 * ### Added classes
 * * `.post_type-{post_type}`
 * * `.post_name-{post_name}`
 * * `.taxonomy-{tax_name}`
 * * `.taxonomy_term-{tax_term_slug}`
 * * `.taxonomy_id-{tax_id}`
 * * `.taxonomy_term_id-{tax_term_id}`
 *
 * @package pp
 * @subpackage boilerplate-theme_filters+hooks
 *
 * @internal Called by `body_class` filter
 *
 */
function pp_body_classes($classes, $class = '')
{
    global $wp_query;
    if (isset($wp_query->queried_object)) {
        // Post type
        if (isset($wp_query->queried_object->post_type)) {
            $classes[] = 'post_type-' . $wp_query->queried_object->post_type;
        }
        // Post name
        if (isset($wp_query->queried_object->post_name)) {
            $classes[] = 'post_name-' . $wp_query->queried_object->post_name;
        }
        // Taxonomy
        if (isset($wp_query->queried_object->taxonomy)) {
            $classes[] = 'taxonomy-' . $wp_query->queried_object->taxonomy;
        }
        // Taxonomy term
        if (isset($wp_query->queried_object->taxonomy)) {
            $classes[] = 'taxonomy_term-' . $wp_query->queried_object->slug;
        }
        // Taxonomy ID
        if (isset($wp_query->queried_object->cat_ID)) {
            $classes[] = 'taxonomy_id-' . $wp_query->queried_object->cat_ID;
        }
        // Taxonomy term ID
        if (isset($wp_query->queried_object->term_id)) {
            $classes[] = 'taxonomy_term_id-' . $wp_query->queried_object->term_id;
        }
    }
    // if isset
    // Has post thumbnail or other acf images, add classes for those
    if (!pp_is_listing()) {
        $classes = pp_post_image_classes($classes);
    }
    // Has comments or not
    if (is_single()) {
        if (comments_open() && get_comments_number()) {
            $classes[] = 'has-comments';
        } else {
            $classes[] = 'no-comments';
        }
        // Comments open/closed
        if (comments_open()) {
            $classes[] = 'can-comment';
        }
    } else {
        $classes[] = 'no-comments';
    }
    // Classes for sidebars
    if (function_exists('pp_sidebar_classes')) {
        $classes[] = pp_sidebar_classes();
    }
    // Class for listing page
    if (pp_is_listing() && !is_home()) {
        $classes[] = 'is-listing-page';
    }
    // return the $classes array
    return $classes;
}
コード例 #2
0
ファイル: index.php プロジェクト: nathansh/penguinpress-theme
         * Include the post type-specific template for the content. If you want to
         * use this in a child theme, then include a file called called content-___.php
         * (where ___ is the post type) and that will be used instead. For post type content layout
         * create a new partials/content-POSTTYPE.php file. If none is found content.php will be used.
         *
         * partials/listing is used on archives and search results, while content is used for
         * full content post/page views.
         */
        if (pp_is_listing()) {
            get_template_part('partials/listing', get_post_type());
        } else {
            get_template_part('partials/content', get_post_type());
        }
    }
    // For listings, add a but of markup
    if (pp_is_listing()) {
        echo '</div>';
    }
    // Pagination
    get_template_part('partials/pagination', get_post_type());
} else {
    // If no content, include the "No posts found" template.
    get_template_part('partials/content', 'none');
}
?>

		</section><!--  .l-content-->

		<?php 
get_sidebar(get_post_type());
?>