目前我有以下
<?php
/*
Template Name: Landing Page Template
*/
get_header();
global $post;
$slug = $post->post_name;
$parent = array(
'hide_empty' => false
, 'parent' => 0
, 'orderby' => 'term_id'
, 'exclude' => array(1, 16)
);
$categories = get_terms( 'category', $parent );
?>
<!-- Banner Image -->
<section class="banner short" style="background-image:url('/wp-content/themes/ewc/assets/img/banners/Banner - Indulge.jpg');"></section>
<!-- Content Section -->
<section class="content category">
<div class="grid-container">
<div class="grid-x grid-margin-x grid-margin-y">
<div class="cell text-center">
<h1><?php the_title(); ?></h1>
</div>
<div class="cell large-3">
<div class="sidebar">
<?php @include('partials/sidebar.php'); ?>
</div>
</div>
<div class="cell large-9">
<div class="main">
<div class="grid-x grid-margin-y">
<?php foreach ( $categories as $category ) : ?>
<?php
$children = array(
'hide_empty' => false
, 'parent' => $category->term_id
, 'orderby' => 'term_id'
);
$subcategories = get_terms( 'category', $children );
?>
<?php foreach ( $subcategories as $subcategory ) : ?>
<div class="cell mar-bott">
<h4 data-target="<?php echo str_replace(' ', '-', strtolower($subcategory->name)); ?>"><?php echo $category->name . '<span>' . $subcategory->name . '</span>'; ?></h4>
<div class="tile-group">
<?php
$args = array (
'post_type' => $slug
, 'category_name' => $subcategory->slug
, 'posts_per_page' => -1
, 'orderby' => 'title'
, 'order' => 'ASC'
);
$posts = get_posts( $args );
?>
<?php foreach ( $posts as $post ) : setup_postdata( $post ); ?>
<div class="tile">
<a href="<?php the_permalink(); ?>" style="background-image:url('<?php the_post_thumbnail_url() ?>');" title="<?php the_title(); ?>">
</a>
</div>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
</div>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
</section>
<?php
get_footer();
?>
我需要完成的只是从自定义帖子类型获取父类别/子类别。我有一个自定义的沉迷帖子类型,目前无论显示哪种帖子类型,所有类别都在显示。我将如何遍历该特定帖子类型的所有类别?