Heim  >  Artikel  >  Backend-Entwicklung  >  wordpress自定义字段输出代码设计_PHP教程

wordpress自定义字段输出代码设计_PHP教程

WBOY
WBOYOriginal
2016-07-14 10:12:071430Durchsuche

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


  


  <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="wordpress自定义字段输出代码设计_PHP教程" >" 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>


这个是幻灯片的实例代码,可以在这个基础上修改自己需要的样式,循环输出

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477221.htmlTechArticle!--举个例子 假如这是一个幻灯片-- div class=flexslider ?php if ( have_posts() ) :the_post(); ? ul class=slides ?php $images = get_post_meta($post-ID, images, false); //一...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn