douzhui1972 2013-09-12 08:10
浏览 32
已采纳

从显示中排除投资组合类别

I want to ask the Portfolio Page Template to exclude one portfolio category from being displayed in the portfolio. So when it shows the categories: All | Travel | Macro | Archive, etc. I need to exclude Archive (slug archive) from both the top filter and from the All feed, because I want to place that on a separate page called Archive.

How do I do that?

<?php
/*
Template Name: Portfolio number 1
*/
?>
<?php get_header(); ?>

<div class="container">

        <div id="homecontent">

            <ul id="portfolio-filter" class="filter clearfix">
                      <li class="active"><a href="javascript:void(0)" class="all">All</a></li>

                      <?php
                          // Get the taxonomy
                          $terms = get_terms('categories');
                                  $term_list = '';

                          // set a count to the amount of categories in our taxonomy
                          $count = count($terms); 

                          // set a count value to 0
                          $i=0;

                          // test if the count has any categories
                          if ($count > 0) {

                              // break each of the categories into individual elements
                              foreach ($terms as $term) {

                                  // increase the count by 1
                                  $i++;

                                  // rewrite the output for each category
                                  $term_list .= '<li><a href="javascript:void(0)" class="'. $term->slug .'">' . $term->name . '</a></li>';

                                  // if count is equal to i then output blank
                                  if ($count != $i)
                                  {
                                      $term_list .= '';
                                  }
                                  else 
                                  {
                                      $term_list .= '';
                                  }
                              }

                              // print out each of the categories in our new format
                              echo $term_list;
                          }
                      ?>
                  </ul>

                  <div style="clear: both;"></div>




                  <ul id="portfolio-list" class="filterable-grid clearfix centerrow filter-posts">

                        <?php 
                          // Set the page to be pagination
                          $paged = get_query_var('paged') ? get_query_var('paged') : 1;

                          // Query Out Database
                          $wpbp = new WP_Query(array( 'post_type' => 'myportfoliotype', 'posts_per_page' =>'99', 'paged' => $paged ) ); 
                        ?>

                        <?php
                          // Begin The Loop
                          if ($wpbp->have_posts()) : while ($wpbp->have_posts()) : $wpbp->the_post(); 
                        ?>

                        <?php 
                          // Get The Taxonomy 'Filter' Categories "categories"
                          $terms = get_the_terms( get_the_ID(), 'categories' ); 
                        ?>

                        <?php 
                        $large_image =  wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'fullsize', false, '' ); 
                        $large_image = $large_image[0]; 
                        $another_image_1 = get_post_meta($post->ID, 'themnific_image_1_url', true);
                        $video_input = get_post_meta($post->ID, 'themnific_video_url', true);
                        $price = get_post_meta($post->ID, 'themnific_item_price', true);
                        $ribbon = get_post_meta($post->ID, 'themnific_class', true);
                        ?>

                        <li class="centerfourcol filter" data-id="id-<?php echo $count; ?>" data-type="<?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->slug)). ' '; } ?>">

                            <?php get_template_part('/includes/folio-types/home_carousel'); ?>

                        </li>


                      <?php $count++; // Increase the count by 1 ?>     
                      <?php endwhile; endif; // END the Wordpress Loop ?>
                      <?php wp_reset_query(); // Reset the Query Loop?>

                  </ul>
                  <?php
                      /* 
                       * Download WP_PageNavi Plugin at: http://wordpress.org/extend/plugins/wp-pagenavi/
                       * Page Navigation Will Appear If Plugin Installed or Fall Back To Default Pagination
                      */        
                      if(function_exists('wp_pagenavi'))
                      {              
                          wp_pagenavi(array( 'query' => $wpbp ) );
                          wp_reset_postdata();  // avoid errors further down the page
                      }
                  ?>
                  <div style="clear: both;"></div>

        </div><!-- #homecontent -->

</div>

<?php get_footer(); ?>
  • 写回答

1条回答 默认 最新

  • doupuchao4256 2013-09-16 14:07
    关注

    I found the answer, the code below only allows one categorie to be displayed in the portfolio.

    ‘tax_query’ => array( array( ‘taxonomy’ => ‘categories’, ‘field’ => ‘slug’, ‘terms’ => ‘archive’, ‘operator’ => ‘IN’) ),
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示