繁体   English   中英

无法在Wordpress中为可过滤的投资组合设置每页号的帖子

[英]Can't set post per page number for filterable portfolio in wordpress

我使用此处找到的教程创建了可过滤的投资组合: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(); ?>

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

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

在我的页面模板中:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM