wordpress custom field output code design_PHP tutorial

WBOY
Release: 2016-07-14 10:12:07
Original
1468 people have browsed it

<!--举个例子 假如这是一个幻灯片-->


  


  <div class="flexslider">


       <?php if ( have_posts() ) :the_post(); ?>


      <ul class="slides">     


        <?php         


                $images = get_post_meta($post->ID, &#39;images&#39;, false); //一会你要添加的自定义字段 images


                if($images){ //开始循环同名自定义字段


                foreach ($images as $image) {


 


                        $fullvalue = explode("|", $image);


                        $post_img=$fullvalue[0]; //图片地址


                        $post_url=$fullvalue[1]; //图片对应的文章地址


                        $img_info=$fullvalue[2]; //图片信息


?>


 


<!--开始输出自定义字段-->


  <li>


  <div class="img_conent">


 <!--幻灯片图片 --> 


   <a title="<?php echo $img_info ?>" href="<?php echo $post_url ?>">


  <img src="<?php echo $full_img ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /></a>


 <!--幻灯片标题--> 


  <div class="img_info"><?php echo $img_info ?></div>


  </div> 


  <!--end img_conent -->


  </li>


        


        <?php


                


                }// end foreach


}                


      endif;  


                ?>


      </ul>


    </div>
Copy after login


This is an example code for a slideshow. You can modify the style you need based on this and loop the output

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477221.htmlTechArticle!--For example, if this is a slide-- div class=flexslider ?php if ( have_posts( ) ) :the_post(); ? ul class=slides ?php $images = get_post_meta($post-ID, images, false); //One...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!