个性化阅读
专注于IT技术分析

动态将图像添加到WordPress中的滑块

点击下载

我是Wordpress的新手。基本上实现了完美运行的滑块。现在最主要的是, 我希望以前由管理员用户上传的图像。我不知道要实现这一目标。请帮我。衷心感谢艾米的帮助。

这是我的代码:-

<aside class="portfolio-right">
  <ul class="mybxslider">
     <li><img src="<?php bloginfo('template_url'); ?>/images/acc-thumbnail-1.jpg" /></li>
     <li><img src="<?php bloginfo('template_url'); ?>/images/acc-thumbnail-2.jpg" /></li>
     <li><img src="<?php bloginfo('template_url'); ?>/images/acc-thumbnail-3.jpg" /></li>
  </ul>
 <script>
    $('.mybxslider').bxSlider({
          adaptiveHeight: true, mode: 'fade'
     });
 </script>
</aside>

#1


创建自定义帖子类型”滑块图像”, 并在该帖子类型中添加滑块图像作为要素图像。

用于显示滑块中使用的图像

<ul class="mybxslider">
<?php
$args = array(  
            'post_type' => 'slider_post', //Post type
            'posts_per_page' => 10                     
            );
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
    while ( $the_query->have_posts() ) {
    $the_query->the_post();

    $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
?>
    <li><img src="<?=$url?>" width="350" height="350" /></li>
<?php } } ?>
</ul>
赞(0)
未经允许不得转载:srcmini » 动态将图像添加到WordPress中的滑块

评论 抢沙发

评论前必须登录!