0

我使用此处的教程创建了一个可过滤的投资组合:http: //zoerooney.com/blog/web-development/filtering-portfolio-quicksand-taxonomies/#comments

一切正常,但我无法设置每页的帖子。我的作品集最多显示在设置>阅读>博客页面中设置的数字。

我尝试使用 '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(); ?>
4

1 回答 1

0

我想到了。我不得不更换:

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

在我的页面模板中使用这个:

$pfportfolio = new WP_Query('paged=$paged&showposts=-1&'.$query."post_type=portfolio");
于 2014-01-29T20:24:58.740 回答