【发布时间】:2014-10-08 22:57:53
【问题描述】:
我正在一个 wordpress 站点中实现同位素脚本,并且当前有以下查询来填充网格。我希望将 Wordpress 页面与帖子一样对待,这可以实现吗?
提前感谢您的帮助。
<?php $the_query = new WP_Query( 'posts_per_page=10' ); //Check the WP_Query docs to see how you can limit which posts to display ?>
<?php if ( $the_query->have_posts() ) : ?>
<div id="isotope-grid">
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
$termsArray = get_the_terms( $post->ID, "category" ); //Get the terms for this particular item
$termsString = ""; //initialize the string that will contain the terms
foreach ( $termsArray as $term ) { // for each term
$termsString .= $term->slug.' '; //create a string that has all the slugs
}
?>
<article class="<?php echo $termsString; ?> isotope-brick">
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} ?>
</article><!-- end article -->
<?php endwhile; ?>
</div> <!-- end isotope-grid -->
【问题讨论】:
标签: wordpress jquery-isotope posts