Php 在wordpress中获取自定义帖子类型中某个类别的所有产品

Php 在wordpress中获取自定义帖子类型中某个类别的所有产品,php,wordpress,Php,Wordpress,我是wordpress的新手,我正在使用RT主题15,我想展示所有内容 自定义邮政类型的产品。当我取产品时,所有的产品都不来 属于特定类别的。15种产品中只有9种 下面是代码,该代码显示了9种产品:- <?php # # rt-theme product loop # global $args,$wp_query; //column $box_counter = 0; if(is_tax()) $args = array_merge( $wp_query->query, $

我是wordpress的新手,我正在使用RT主题15,我想展示所有内容

自定义邮政类型的产品。当我取产品时,所有的产品都不来

属于特定类别的。15种产品中只有9种

下面是代码,该代码显示了9种产品:-

<?php
# 
# rt-theme product loop
#
global $args,$wp_query; 

//column

$box_counter = 0;

if(is_tax()) $args = array_merge( $wp_query->query, $args);

query_posts($args); 

$product = array();
$postCount = 0;

if ( have_posts() ) : while ( have_posts() ) : the_post();


?>

    <?php
    //box class

    $product[$postCount]['title']       =   get_the_title();
    $product[$postCount]['thumb']       =   find_image_org_path(get_post_meta($post->ID, THEMESLUG.'product_image_url', true));
    $product[$postCount]['image']       =   @vt_resize( '', $thumb, $w, $h, ''.$crop.'' );
    $product[$postCount]['short_desc']  =   get_post_meta($post->ID, THEMESLUG.'short_description', true);
    $product[$postCount]['permalink']   =   get_permalink();
    $product[$postCount]['watt']        =   get_post_meta($post->ID, 'wpcf-watt', true);    

    $postCount = $postCount + 1;
    ?>

<?php endwhile?>
<?php

    echo "<pre>";print_r($product);



?>

<?php endif; wp_reset_query();?>

但我想把所有的产品都放入阵列中。我不知道如何展示所有的产品和服务

我必须更改设置以显示所有产品

  • 您可以在function.php文件中使用此代码设置计数

  • 您可以从管理面板设置帖子数量-

    1] 转到仪表板>设置

    2] 然后读取设置

    3] 在那个固定的岗位上数到15

    4] 然后保存更改


您可以在查询中使用参数
每页发布
。将其设置为-1,它将获取所有帖子。 比如说:
$args['posts\u per\u page']=-1;查询职位($args)

function change_posts_per_page( $query ) 
{
  $query->set( 'posts_per_page', 5 );
 }
add_action( 'pre_get_posts', 'change_posts_per_page' );