【发布时间】:2014-03-06 05:51:15
【问题描述】:
我正在使用这个 Wordpress 插件:http://wordpress.org/plugins/carousel-of-post-images/ 它显示一个帖子滑块并显示特色图像。 当前设置为按 id 显示帖子,这些帖子需要单独输入到短代码中。是否可以按类别显示帖子,以便我可以设置帖子的类别并在滑块中仅查看该类别?
这是我认为负责的所有代码。
function copi_carousel_get_images($size = 'medium' , $orderby, $posts, $count, $class = ''){
global $post;
$att_array = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => $orderby,
'numberposts' => $count,
);
$postlist = explode(",",$posts);
$sizes = explode(",", $size);
$html = '';
if (count($sizes) == 2)
{
$width = $sizes[0];
$height = $sizes[1];
$size=$sizes;
}
else
{
$width = get_option($size.'_size_w');
$height = get_option($size.'_size_h');
}
foreach($postlist as $postid)
{
if ($postid != '')
$att_array['post_parent'] = $postid;
$attachments = get_posts($att_array);
if (is_array($attachments)){
foreach($attachments as $att){
$image_src_array = wp_get_attachment_image_src($att->ID, $size);
$url = $image_src_array[0];
if ($url != "")
{
$prefix = '<li><a href="'.get_permalink($att->post_parent).'">';
$suffix = "</a></li>";
$caption = $att->post_excerpt;
if(function_exists('thumbGen'))
$url = thumbGen($url, $width, $height, 'return=1');
$image_html = '<img src="%s" height="'.$height.'" alt="%s">';
$html .= $prefix.sprintf($image_html,$url,$caption,$class).$suffix;
}
}
}
}
return $html;
}
function show_wp_copi_carousel($atts){
$skin = 'tango';
$div='post-carousel';
$imagesize = 'medium';
$orderby = 'rand';
$postid = '';
$count='10';
if (isset($atts['skin']))
$skin = $atts['skin'];
if (isset($atts['imagesize']))
$imagesize = $atts['imagesize'];
if (isset($atts['orderby']))
$orderby = $atts['orderby'];
if (isset($atts['postid']))
$postid = $atts['postid'];
if (isset($atts['count']))
{
$count = $atts['count'];
【问题讨论】:
-
您好,虽然很老了,但是这个帖子没有得到插件作者的回复:wordpress.org/support/topic/… 这表明这个功能在这个插件中并不容易实现。我建议寻找替代方案,而不是尝试重新编写此插件。
-
谢谢,我查看了插件的支持论坛,最后一篇帖子已经 3 个月了,没有回复,这是一个相当简单的请求,让我相信开发人员不太重视支持。我可能是错的,但作者没有回复我并没有“暗示这个功能在这个插件中不容易实现”。如果是,那就这样吧,但我已经花了很多时间寻找没有运气的替代品,这个插件最接近我需要的。
-
当然,有时插件的作者只是错过了帖子或由于其他原因不回复......但我在支持论坛上看了看,也看到了这个wordpress.org/support/topic/images-from-custom-post-type-cpt,这表明它并不意味着非常可定制。