簡體   English   中英

如何通過視覺作曲家在前端WordPress頁面上顯示圖像?

[英]How to show image on front end WordPress page by visual composer?

function italy_menu( $menu1, $menu2 ){
    ob_start();

    $menuatts = shortcode_atts(array(
        'menu_image'    =>  '',
        'menu_title'    =>  '',
        'menu_money'    =>  '',
    ), $menu1 );

?>
    <div class="post">
        <a href="#"><img src="<?php echo $menuatts['menu_image']; ?>"/></a>
        <div class="wrapper">
          <h5><a href="#"><?php echo $menuatts['menu_title']; ?></a></h5>
          <span><?php echo $menuatts['menu_money']; ?></span>
        </div>
    </div>
<?php
    return ob_get_clean();
}
add_shortcode('menu','italy_menu');


if(function_exists(vc_map)){
    vc_map(array(
        'name'  =>  'Italy Food Menu',
        'base'  =>  'menu',
        'params'    =>  array(
            array(
                'param_name'        =>  'menu_image',
                'type'              =>  'attach_images',// How to show image on front page.
                'heading'           =>  'Menu Image'
            ),
            array(
                'param_name'        =>  'menu_title',
                'type'              =>  'textfield',
                'heading'           =>  'Menu Title'
            ),
            array(
                'param_name'        =>  'menu_money',
                'type'              =>  'textfield',
                'heading'           =>  'Menu Money'
            ),
        )
    ));
}

如何通過視覺作曲家在前端WordPress頁面上顯示圖像? 我想由視覺作曲家在前端顯示圖像。 我正在使用> 'type' => 'attach_images',但是它沒有顯示圖像...這是我的代碼。

$ gallery = shortcode_atts(array('post_gallery'=>'post_gallery',),$ atts);

    $image_ids=explode(',',$gallery['post_gallery']);
    $sigle_img = wp_get_attachment_image_src($image_ids[0], "large");
    $img="<div id='tourGallery'><img class='imgthumb' id='' src='".$sigle_img[0]."' style='width:100%' alt=''></div><div id='galleryThumbs'>";
    for($i=0;$i<=9;$i++)
    {
     if($image_ids[$i]!="")
      {
      $imgs = wp_get_attachment_image_src($image_ids[$i], "large"); 
      $img.="<div><img class='imgthumb' id='' src='".$imgs[0]."' style='width:100%' alt=''></div>";
      }
    }
    $img.="</div></div>";
    return $img;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM