0

ここにあるチュートリアルを使用して、フィルター可能なポートフォリオを作成しました: http://zoerooney.com/blog/web-development/filtering-portfolio-quicksand-taxonomies/#comments

すべてが機能していますが、ページごとに投稿を設定できません。私のポートフォリオは、Setting>Reading>Blog Pages Show at Most で設定された数だけ表示されます。

'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 に答える