admin管理员组文章数量:1130349
I managed to use Radiant Scroller to create a slider grid of posts for my custom post type (zee_work). It serves as a display of portfolio items in a very clean neat way, but I need to filter the posts in order to show all the posts (default) and any other category (that number could change if I add more categories).
The code I have is this:
<?php
$works = get_posts(
array(
'post_type'=>'zee_work',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => -1 ) );
?>
<div id="portfolio" class="clearfix">
This is the grid slider (working smooth):
<div id="myScroller">
<?php foreach ($works as $key => $work) {
?>
<div class="scroller-el">
<a href="<?php the_permalink($work->ID)?>">
<?php echo get_the_post_thumbnail( $work->ID, 'work-thumb', array(
'class' => "img-responsive",
'alt' => trim(strip_tags( $work->post_title )),
'title' => trim(strip_tags( $work->post_title ))
)); ?> </a>
</div>
<?php } ?>
</div>
</div>
How do I do a foreach of every category (custom tax) on my zee_work posts to filter the slider? I need help! :c
UPDATE
I managed to add a filter on top using isotope and the filtering works BUT the default view (all) 'hardcodes' the pagination so if for example, the first time the page loads with all the items the slider has 3 pages, the filtering that occurs next will keep 3 pages even if items fit in only one, and the items are distributed in all 3 pages so it leaves empty spaces in the grid.... oh boy...
<ul class="portfolio-filter">
<li><a class="btn btn-default active" href="#" data-filter="*">
<?php _e('All', ZEETEXTDOMAIN); ?></a></li>
<?php
$terms = get_terms('cat_work', array('hide_empty'=> true));
foreach ($terms as $term) {
?>
<li><a class="btn btn-default" href="#" data-filter=".<?php echo $term->slug ?>"><?php echo $term->name ?></a></li>
<?php
}
?>
</ul>
I managed to use Radiant Scroller to create a slider grid of posts for my custom post type (zee_work). It serves as a display of portfolio items in a very clean neat way, but I need to filter the posts in order to show all the posts (default) and any other category (that number could change if I add more categories).
The code I have is this:
<?php
$works = get_posts(
array(
'post_type'=>'zee_work',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => -1 ) );
?>
<div id="portfolio" class="clearfix">
This is the grid slider (working smooth):
<div id="myScroller">
<?php foreach ($works as $key => $work) {
?>
<div class="scroller-el">
<a href="<?php the_permalink($work->ID)?>">
<?php echo get_the_post_thumbnail( $work->ID, 'work-thumb', array(
'class' => "img-responsive",
'alt' => trim(strip_tags( $work->post_title )),
'title' => trim(strip_tags( $work->post_title ))
)); ?> </a>
</div>
<?php } ?>
</div>
</div>
How do I do a foreach of every category (custom tax) on my zee_work posts to filter the slider? I need help! :c
UPDATE
I managed to add a filter on top using isotope and the filtering works BUT the default view (all) 'hardcodes' the pagination so if for example, the first time the page loads with all the items the slider has 3 pages, the filtering that occurs next will keep 3 pages even if items fit in only one, and the items are distributed in all 3 pages so it leaves empty spaces in the grid.... oh boy...
<ul class="portfolio-filter">
<li><a class="btn btn-default active" href="#" data-filter="*">
<?php _e('All', ZEETEXTDOMAIN); ?></a></li>
<?php
$terms = get_terms('cat_work', array('hide_empty'=> true));
foreach ($terms as $term) {
?>
<li><a class="btn btn-default" href="#" data-filter=".<?php echo $term->slug ?>"><?php echo $term->name ?></a></li>
<?php
}
?>
</ul>
本文标签: Grid slider with custom post type (how to filter with taxonomies)
版权声明:本文标题:Grid slider with custom post type (how to filter with taxonomies?) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749020954a2304363.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论