动态添加图像到wordpress中的滑块

时间:2014-12-26 12:29:27

标签: php wordpress wordpress-plugin wordpress-theming

我是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 个答案:

答案 0 :(得分:0)

创建自定义帖子类型Slider Images&amp;将滑块图像添加为该帖子类型中的要素图像。
用于显示滑块中的图像使用

<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>
相关问题