1

CMSで指定されている投稿制限(12に設定)を上書きしたい。Wordpress Codexで見つけた引数に「posts_per_page」を追加しましたが、機能していません。

この検索コードは、CookingPressテーマからのものです。

質問:引数'posts_per_page' => 24が機能しないのはなぜですか?

<?php 
if ($_GET['submit']) {

    $args = array(
            'posts_per_page' => 24,
            'tax_query' => array(
                    'relation' => 'AND'
            )
            ,'post_type' => 'post'
    );

    $cat = mysql_real_escape_string($_GET['cat']);
    $categories = array();
    if($cat) {
        $categories = array (
                'taxonomy' => 'category',
                'field' => 'term_id',
                'terms' => array( $cat )
        );
        array_push($args['tax_query'],$categories);
    }

    $level = mysql_real_escape_string($_GET['level']);
    $levels = array();
    if($level) {
        $levels = array (
                'taxonomy' => 'level',
                'field' => 'slug',
                'terms' => array( $level )
        );
        array_push($args['tax_query'],$levels);
    }

    $serving = mysql_real_escape_string($_GET['serving']);
    if($serving) {
        $servings = array (
                'taxonomy' => 'serving',
                'field' => 'slug',
                'terms' => array( $serving )
        );
        array_push($args['tax_query'],$servings);
    }

    $time = mysql_real_escape_string($_GET['timeneeded']);
    if($time) {
        $times = array (
                'taxonomy' => 'timeneeded',
                'field' => 'slug',
                'terms' => array( $time )
        );
        array_push($args['tax_query'],$times);
    }


    $allergen = $_GET['allergens'];
    if($allergen) {
        $allergens = array (
                'taxonomy' => 'allergen',
                'field' => 'slug',
                'terms' => $allergen
        );
        array_push($args['tax_query'],$allergens);
    }

    $tags = $_GET['include_ing'];

    if($_GET['relation']=='all') {
        if($tags) {
            foreach ($tags as $t) {
                $tagsquery = array (
                        'taxonomy' => 'post_tag',
                        'field' => 'slug',
                        'terms' => mysql_real_escape_string($t)
                );
                array_push($args['tax_query'],$tagsquery);
            }
        }
    } else {
        if($tags) {
            $tagsquery = array (
                    'taxonomy' => 'post_tag',
                    'field' => 'slug',
                    'terms' => $tags
            );

            array_push($args['tax_query'],$tagsquery);
        }
   }

    $extags = $_GET['exclude_ing'];
    if($extags) {
            $extagsquery = array (
                    'taxonomy' => 'post_tag',
                    'field' => 'slug',
                    'terms' => $extags,
                    'operator' => 'NOT IN'
            );
            array_push($args['tax_query'],$extagsquery);
        }

    if(!$wp_query) global $wp_query;
    $args = array_merge( $args , $wp_query->query );
    query_posts( $args);

}
?>
4

1 に答える 1

3

考えられる解決策

nopagingパラメータを次のように設定してみてくださいfalse

$args = array(
  'posts_per_page' => -1,
  'nopaging' => false,
  'post_type' => 'post'
);

参照

コーデックス:ページ付けパラメーター

于 2014-02-09T14:51:29.850 に答える