Woocommerce search.php

时间:2017-06-16 12:13:32

标签: wordpress search woocommerce show price

如何在Woocommerce中为'search.php'添加价格?

目前的代码是:

<?php
get_header();
global $wp_query;
?>
<div class="wapper">
  <div class="contentarea clearfix">
    <div class="content">
  <h1 class="search-title"> <?php echo $wp_query->found_posts; ?>
        <?php _e( 'Search Results Found For', 'locale' ); ?>: "<?php the_search_query(); ?>" </h1>
        <?php if ( have_posts() ) { ?>
            <ul>
            <?php while ( have_posts() ) { the_post(); ?
               <hr width=“20%”>
                 <h3><b><a href="<?php echo get_permalink(); ?>"></b>
                   <?php the_title();  ?>
                 </a></h3>
                 <?php  the_post_thumbnail( 'shop_thumbnail' ) ?>
                 <br/>
                 <div class="h-readmore"> <a href="<?php the_permalink(); ?>"><I>Click to see full details</I></a></div>
               </hr width=“20%”>
            <?php } ?>   
            </ul>  
           <?php paginate_links(); ?>  
        <?php } ?>  
    </div>
  </div>
</div>
<?php
do_action( 'storefront_sidebar' );
get_footer();

这也有侧边栏而不是侧边 - 所以如果有人可以建议如何在LEFT上设置侧边栏也有帮助。

1 个答案:

答案 0 :(得分:0)

<?php
get_header();
global $wp_query;
?>
<div class="wapper">
  <div class="contentarea clearfix">
    <div class="content">
  <h1 class="search-title"> <?php echo $wp_query->found_posts; ?>
        <?php _e( 'Search Results Found For', 'locale' ); ?>: "<?php the_search_query(); ?>" </h1>
        <?php if ( have_posts() ) { ?>
            <ul>
            <?php while ( have_posts() ) { the_post(); ?>
               <hr width=“20%”>
                 <h3><b><a href="<?php echo get_permalink(); ?>"></b>
                   <?php the_title();  ?>
                 </a></h3>
                 <?php  the_post_thumbnail( 'shop_thumbnail' ) ?>
                 <br/>
                 <p itemprop="price" class="price"><?php echo $product->get_price_html(); ?></p>
                 <div class="h-readmore"> <a href="<?php the_permalink(); ?>"><I>Click to see full details</I></a></div>
               </hr width=“20%”>
            <?php } ?>   
            </ul>  
           <?php paginate_links(); ?>  
        <?php } ?>  
    </div>
  </div>
</div>
<?php
do_action( 'storefront_sidebar' );
get_footer();

使用以上代码更新search.php,我们可以使用此<p itemprop="price" class="price"><?php echo $product->get_price_html(); ?></p>

调用该价格