产物展现用到文章和缩略图功用
相干引荐:《WordPress教程》
完成步骤:
一、建立分类
背景建立文章分类:产物中间
二、开启缩略图功用
在主题的functions.php中,增加一段代码,代码以下:
add_theme_support( 'post-thumbnails' );
更多设置请参考:
http://www.cnblogs.com/tinyphp/p/6359167.html
三、增加文章并设置缩略图
四:挪用该分类信息、文章题目和缩略图
<div class="section sectionL"> <?php $product_term =get_term_by('name','产物中间',category); $product_term_id=$product_term->term_id; $product_link=get_term_link($product_term_id,'category'); ?> <h2> <a href="<?php echo $product_link?>">产物中间</a> <span><a href="<?php echo $product_link;?>"></a></span> </h2> <ul> <?php $product_query=new WP_Query(array( 'cat'=>2, 'posts_per_page'=>8 )); if($product_query->have_posts()) : while($product_query->have_posts()) :$product_query->the_post(); ?> <li> <a href="<?php the_permalink();?>"> <?php if ( has_post_thumbnail() ) : ?> <?php the_post_thumbnail( 'thumbnail' ); ?> <?php else: ?> //显现默许图片 <?php endif; ?> </a> <h3><a href="<?php the_permalink();?>"><?php the_title();?>dd</a></h3> </li> <?php endwhile;?> <?php endif;?> </ul> </div>
以上就是wordpress如何做产物展现页的细致内容,更多请关注ki4网别的相干文章!