Last active
December 21, 2015 06:19
-
-
Save mypacecreator/6263158 to your computer and use it in GitHub Desktop.
get_termsとget_postsの入れ子例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$taxonomies = get_terms( | |
'faqcategory',array( | |
'orderby' => 'slug', | |
'order' => 'ASC' | |
)); | |
foreach($taxonomies as $taxonomy) : | |
?> | |
<div class="parentBox"> | |
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<h2><?php echo $taxonomy->name; ?></h2> | |
<ul> | |
<?php | |
global $post; | |
$faqposts = get_posts( array ( | |
'post_type' => 'faq', | |
'taxonomy' => 'faqcategory', | |
'term' => $taxonomy->slug | |
)); | |
foreach($faqposts as $post): | |
setup_postdata($post); | |
?> | |
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> | |
<?php endforeach; wp_reset_postdata(); ?> | |
</ul> | |
</div> | |
</div><!-- /.parentBox --> | |
<?php endforeach; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment