Home >CMS Tutorial >WordPress >How to create a product display page in WordPress
The steps to implement a product display page in WordPress are as follows:
1. Create a category
Create article categories in the background: Product Center
2. Turn on the thumbnail function
In the functions of the theme. In php, add a piece of code, the code is as follows:
add_theme_support( 'post-thumbnails' );
3. Add the article and set the thumbnail
4. Call the Classification information, article titles and thumbnails
<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>
For more wordpress-related technical articles, please visit the wordpress tutorial column to learn!
The above is the detailed content of How to create a product display page in WordPress. For more information, please follow other related articles on the PHP Chinese website!