Home  >  Article  >  CMS Tutorial  >  How to create a product display page in WordPress

How to create a product display page in WordPress

尚
Original
2019-07-19 16:28:565348browse

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

How to create a product display page in WordPress

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(&#39;name&#39;,&#39;产品中心&#39;,category);
    $product_term_id=$product_term->term_id;
    $product_link=get_term_link($product_term_id,&#39;category&#39;);
?>
    <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(
            &#39;cat&#39;=>2,
            &#39;posts_per_page&#39;=>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( &#39;thumbnail&#39; ); ?>
            <?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!

Statement:
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