繁体   English   中英

页面上有多个自定义帖子循环

[英]Multiple custom post loops on page

显示第一个循环后,我无法显示第二个或第三个循环。 在过去的两个小时里,我一直在尝试不同的事情,但是我的想法已经耗尽。

这就是我现在所拥有的

<?php
$type = 'new_trucks';
$args=array(
 'orderby' => 'rand',
 'post_type' => $type,
 'paged' => $paged,
 'posts_per_page' => 3,
);

$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query($args);
?>

<?php while (have_posts()) : the_post(); ?>
...
<?php endwhile; /* End loop */ ?>
<?php wp_reset_query(); ?>

第二个循环就像这样,就在上面显示的第一个循环之下...

<?php
$type = 'used_trucks';
$args=array(
 'orderby' => 'rand',
 'post_type' => $type,
 'paged' => $paged,
 'posts_per_page' => 3,
);

$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query($args);
?>

<?php while (have_posts()) : the_post(); ?>
...
<?php endwhile; /* End loop */ ?>
<?php wp_reset_query(); ?>

在尝试用相同的类型集在同一页面中复制该内容时,第二个循环根本没有显示。 如果我删除了第一个循环,它将起作用。 我希望有人可以提供一些指导。

谢谢!

<?php
$type = 'new_trucks';
$args=array(
 'orderby' => 'rand',
 'post_type' => $type,
 'paged' => $paged,
 'posts_per_page' => 3,
);

$wp_query = null;
$wp_query = new WP_Query($args);

?>

<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
...
<?php endwhile; /* End loop */ ?>
<?php wp_reset_query(); ?>

过去是我做的

暂无
暂无

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

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