2017-06-16 50 views
0

如何將價格添加到Woocommerce中的'search.php'中?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這也將有助於側邊欄。

回答

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>

+0

感謝電話,但我想修改上面的代碼,以達到所需的結果。 您引用的插件與網站上的其他人衝突。 我希望保留左側的側邊欄並顯示價格。 謝謝 – sprogg

+0

好的我有更新的答案,請檢查它 –

+0

這裏是結果http://prntscr.com/fkrx2b –