<ul id="thumbs" class="portfolio">
<?php
$loop = new WP_Query( array(
'showposts' => 8,
'post_type' => array('portfolioo'),
$catIDs = get_cat_ID( $cat_name='Graphic design' ),
$catIDs .= ',' . get_cat_ID( $cat_name='Icons' ),
$catIDs .= ',' . get_cat_ID( $cat_name='web-design' ),
)
);
while ( $loop->have_posts() ) : $loop->the_post();
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
?>
<!-- Item Project and Filter Name -->
<li class="item-thumbs col-lg-3 design" data-id="id-0" data-type="<?php echo $catIDs; ?>">
<!-- Fancybox - Gallery Enabled - Title - Full Image -->
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="Portfolio name" href="<?php echo $image[0]; ?>">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $catIDs; ?>" alt="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elementum odio. Curabitur pellentesque, dolor vel pharetra mollis.">
</li>
<!-- End Item Project -->
<?php endwhile; ?>
</ul>
我有一个自定义的帖子类型名称组合,其中有三个类别图标,网页,图形,并且都有图像。如何根据wordpress中的循环显示
答案 0 :(得分:0)
你在代码中做了一些奇怪的事情,但我认为你需要解决这个问题;除非您使用自定义分类法...然后您需要“tax_query”而不是“category__in”。
$loop = new WP_Query(
array(
'showposts' => 8,
'post_type' => array('portfolioo'),
'category__in' => array( get_cat_ID( 'Graphic design' ), get_cat_ID( 'Icons' ), get_cat_ID( $cat_name='web-design' ) )
)
);