ACF +同位素:过滤后对象数据

时间:2016-10-04 21:37:55

标签: wordpress advanced-custom-fields isotope

我正在尝试根据类别从名为“客户端”的自定义帖子类型中过滤数据。我需要出现的是每个特定客户的标识。

我已经设置了Post Objects的转发器字段,因此我可以更改徽标的显示顺序。

我目前的工作原理,但是我无法弄清楚如何合并Post Object选择器,因此显示的内容取决于我通过Repeater添加的实例。

Here is the link to the site.感谢任何答案!

请参阅下面的仪表板设置屏幕截图:

enter image description here

<ul id="filters">
                    <?php 
                        $terms = get_terms("category", array(
                            'orderby' => 'slug'
                        )); // get all categories, but you can use any taxonomy
                        $count = count($terms); //How many are they?
                        if ( $count > 0 ){  //If there are more than 0 terms
                            foreach ( $terms as $term ) {  //for each term:
                                echo "<li><a href='#' data-filter='.".$term->slug."'>" . $term->name . "</a></li>\n";
                                //create a list item with the current term slug for sorting, and name for label
                            }
                        } 
                    ?>
                </ul>


                <?php $the_query = new WP_Query(array(
                    'post_type' => 'clients',
                    'posts_per_page' => '-1',
                    'order' => 'ASC'
                    )); //Check the WP_Query docs to see how you can limit which posts to display ?>

                <?php if ( $the_query->have_posts() ) : ?>
                    <div class="isotope-list-container">
                        <div id="isotope-list" class="row small-up-1 medium-up-2 large-up-3">
                        <?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 
                            }
                        ?> 
                        <div class="<?php echo $termsString; ?> portfolio columns"> <?php // 'portfolio' is used as an identifier (see Setp 5, line 6) ?>
                            <div class="portfolio-item-container">
                                <?php 
                                    $image = get_field('logo');
                                    if( !empty($image) ): ?>
                                        <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
                                    <?php endif; ?>
                                </div>
                        </div> <!-- end portfolio item -->
                        <?php endwhile;  ?>
                        </div> <!-- end isotope-list -->
                    </div>
                <?php endif; ?>
                <?php wp_reset_query(); ?>

1 个答案:

答案 0 :(得分:0)

通过使用Post Types Order插件重新排序我的帖子,我能够使这个变得更加简单。

https://wordpress.org/plugins/post-types-order/