php cpt同位素循环 - 将术语附加为过滤类

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php cpt同位素循环 - 将术语附加为过滤类相关的知识,希望对你有一定的参考价值。

<!-- I run this inside a loop in archive-cptname.php-->

<div class="col-xs-6 col-sm-3 isotope <?php $terms_as_text = get_the_term_list( $post->ID,'portfolio_category', '', ', ');
	if (!empty($terms_as_text)) echo '', strip_tags($terms_as_text) ,''; ?>">
	<figure class="port-caption">

		<?php the_post_thumbnail( 'portfolio_thumb', array( 'class' => 'port-thumb' ) ); ?>

		<figcaption class="port-caption-text" style="background:<?php the_field('hover_color'); ?>;">
			<a href="<?php the_permalink(); ?>"><?php the_title( '<h3 class="portfolio-title">', '</h3>' ); ?></a>

			<?php $terms_as_text = get_the_term_list( $post->ID,'portfolio_category', '', ', ');
			if (!empty($terms_as_text)) echo '<p>', strip_tags($terms_as_text) ,'</p>'; ?>

		</figcaption>
	</figure>
</div>




<!--then filter stuff like so... there is a better way to do this-->

<section class="blackbar">
	<div class="container">
		<div class="row">
			<div class="col-md-12">

					<div class="portfolioFilter">
						<a href="#" data-filter="*" class="current">All Categories</a>
						<a href="#" data-filter=".Transit">Transit</a>
						<a href="#" data-filter=".Place">Place Based</a>
						<a href="#" data-filter=".Billboard">Billboard</a>
						<a href="#" data-filter=".Technology">Technology</a>
						<a href="#" data-filter=".Interactive">Interactive</a>
						<a href="#" data-filter=".Stadium">Stadium</a>
						<a href="#" data-filter=".Retail">Retail</a>
					</div>

			</div>
		</div>
	</div>
</section>






<!--instantiate isotope and set options-->

<script>

	jQuery(function ($) {

  var $container = $('.row.portfolio'); //The ID for the list with all the blog posts
  $container.isotope({ //Isotope options, 'item' matches the class in the PHP
  	itemSelector : '.isotope', 
  	layoutMode : 'masonry'
  });

  //set filters

  $('.portfolioFilter a').click(function(){
  	$('.portfolioFilter .current').removeClass('current');
  	$(this).addClass('current');

  	var selector = $(this).attr('data-filter');
  	$container.isotope({
  		filter: selector,
  		animationOptions: {
  			duration: 750,
  			easing: 'linear',
  			queue: false
  		}
  	});
  	return false;
  }); 

});

</script>

以上是关于php cpt同位素循环 - 将术语附加为过滤类的主要内容,如果未能解决你的问题,请参考以下文章

php 此功能将术语附加到帖子

通过Wordpress循环通过ID循环CPT

Foreach 循环遍历 cpt 类别以使用 ACF 值

如何在帖子类型“页面”上更改CPT循环的摘录长度?

php 将特色图像添加到CPT [联系人]仪表板列表

php 在“前端布局”列表中显示“自定义帖子类型”。 Upfront隐藏'产品'CPT,因为它依赖于电子商务插件,此过滤器将显示CPT i