下記はwoocommerceの新着の場合

ポイントはpost_type=product

<div class="news">  
        <div class="headline_title">最新登録商品</div>   
        <div class="newssection">   
          <?php $posts = get_posts('post_type=product&numberposts=10&order=desc');
foreach($posts as $post): ?>
          <div class="news-title">
  <p>
    <span class="date"><?php the_time('Y/m/d'); ?></span><br />
    
    <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'link to %s', 'shanghaistudio' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a> <br />
    <?php
 if(mb_strlen($post->post_content)>60) { $content= mb_substr($post->post_content,0,60) ; echo $content. ・・・ ;
} else {echo $post->post_content;}?>
    
  </p>
          </div>
          <?php endforeach; ?>
          <a href="<?php bloginfo(url); ?>/shop/" class="allnews">新着一覧</a>   
        </div>
      </div>

 

見ていただいてありがとうございます。↓ポチしてくださいませ。
  • 見た (0)
  • もう少し詳しく書いて! (0)
  • 見たけど役立たず (0)