2014-01-26 26 views
0

設置每頁數職位篩選的組合,我創建使用這裏找到教程過濾組合:http://zoerooney.com/blog/web-development/filtering-portfolio-quicksand-taxonomies/#comments不能在WordPress

一切工作,但我不能設置每頁我的職務。我的投資組合按照「設置」>「閱讀」>「博客頁面顯示最多」中設置的數字。

我試過'posts_per_page'=>' - 1'但它不起作用。也許我把它放在了錯誤的地方。

這是我的功能代碼文件爲我的自定義後類型和類別爲我的投資組合項目:

register_taxonomy("pftype", array("portfolio"), array("hierarchical" => true,"label" => "Project Types", "singular_label" => "Project Type")); 





add_action('init', 'cptui_register_my_cpt_portfolio'); 
function cptui_register_my_cpt_portfolio() { 
register_post_type('portfolio', array(
'label' => 'Portfolio', 
'description' => '', 
'public' => true, 
'show_ui' => true, 
'show_in_menu' => true, 
'capability_type' => 'post', 
'map_meta_cap' => true, 
'hierarchical' => false, 
'rewrite' => array('slug' => 'portfolio', 'with_front' => true), 
'query_var' => true, 
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'), 
'labels' => array (
    'name' => 'Portfolio', 
    'singular_name' => 'Portfolio', 
    'menu_name' => 'Portfolio', 
    'add_new' => 'Add Portfolio', 
    'add_new_item' => 'Add New Portfolio', 
    'edit' => 'Edit', 
    'edit_item' => 'Edit Portfolio', 
    'new_item' => 'New Portfolio', 
    'view' => 'View Portfolio', 
    'view_item' => 'View Portfolio', 
    'search_items' => 'Search Portfolio', 
    'not_found' => 'No Portfolio Found', 
    'not_found_in_trash' => 'No Portfolio Found in Trash', 
    'parent' => 'Parent Portfolio', 
) 
)); } 

這是我使用我的投資組合代碼:

<?php 
/** 
* Template Name: Portfolio 
*/ 
?> 

<?php get_header(); ?> 

<ul class="load-portfolio"> 
     <li class="active"><a href="#" class="all">All</a></li> 
     <?php 
     $args = array('taxonomy' => 'pftype'); 
     $terms = get_terms('pftype', $args); 
     $count = count($terms); $i=0; 
     if ($count > 0) { 
      $cape_list = ''; 
      foreach ($terms as $term) { 
       $i++; 
       $term_list .= '<li><a href="#" class="'. $term->name .'">' . $term->name . '</a></li>'; 
       if ($count != $i) $term_list .= ''; else $term_list .= ''; 
      } 
      echo $term_list; 
     } 
     ?> 
    </ul> 

<ul class="portfolio-grid"> 
     <?php 


     $pfportfolio = new WP_Query('post_type=portfolio'); 


     while ($pfportfolio->have_posts()) : $pfportfolio->the_post();?> 


     <?php 
      echo '<li data-id="post-'.get_the_ID().'" data-type="'.$terms_as_text = strip_tags(get_the_term_list($post->ID, 'pftype', '', ' ', '')).'">'; 
      ?> 
      <div class="item"> 
         <div class="view third-effect"> 
      <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>"><?php the_post_thumbnail('homepage-thumb'); ?></a> 
      <?php 

      ?> 
      <div class="mask"> 
          </div> 
      <div class="item-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></div> 
      </div> 
      </div> 
      <?php 

      echo '</li>'; 
     endwhile; 

     wp_reset_postdata(); 
     ?> 
    </ul> 


<?php get_footer(); ?> 

回答

0

我想通了。我不得不更換:

$pfportfolio = new WP_Query('post_type=portfolio'); 

有了這個在我的頁面模板:

$pfportfolio = new WP_Query('paged=$paged&showposts=-1&'.$query."post_type=portfolio");