特定类别的Wordpress twitter引导图像旋转木马

特定类别的Wordpress twitter引导图像旋转木马,wordpress,twitter-bootstrap,carousel,Wordpress,Twitter Bootstrap,Carousel,我正在使用320press的引导主题,目前正在努力使用图像滑块旋转木马。当我只需要一个特定的类别时,它会显示网站上每个特色图片的帖子。我猜这是下面的代码,我必须调整som的方式 <?php global $post; $tmp_post = $post; $show_posts = of_get_option('slider_options'); $args = array( '2' => $show_posts ); // set this to how many posts yo

我正在使用320press的引导主题,目前正在努力使用图像滑块旋转木马。当我只需要一个特定的类别时,它会显示网站上每个特色图片的帖子。我猜这是下面的代码,我必须调整som的方式

<?php
global $post;
$tmp_post = $post;
$show_posts = of_get_option('slider_options');
$args = array( '2' => $show_posts ); // set this to how many posts you want in the carousel
$myposts = get_posts( $args );
$post_num = 0;
foreach( $myposts as $post ) :  setup_postdata($post);
    $post_num++;
    $post_thumbnail_id = get_post_thumbnail_id();
    $featured_src = wp_get_attachment_image_src( $post_thumbnail_id, 'wpbs-featured-carousel' );
?>

尝试将
get_posts()
$args
替换为以下内容。你需要在你想展示的类别中加入slug。因为我不知道这个插件是如何工作的,所以我不能保证它能像预期的那样工作

$args=array(
“每页帖子”=>$show\u帖子,
'category\u name'=>'your\u category\u slug'
);

您可以在WordPress codex的WP_查询页面上看到
get_posts()
可用参数的完整列表:


我被你的代码设置的计数器搞糊涂了。似乎将要获取的帖子数量设置为
get_posts()
的参数会更有意义。

你从哪里获取的代码?老实说,我不知道。认为它来自page-homepage.php的原始GitHub代码。更多信息:get_posts()的参数看起来不正确。至少它是有效的。我认为这些参数不起作用-因为它们是无效的,可能会被忽略,所有的帖子都会被返回。