2017-11-02 15 views
0

ループ内でwp_trim_wordsとwp_strip_all_tagsを組み合わせるソリューションが見つかりません。 これは私が今持っているものです。wp_trim_wordsとwp_strip_all_tagsを組み合わせる

<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?> 
     <div class="news-el"> 
      <a href="<?php the_permalink(); ?>"> 
       <div class="news-content">      
        <h3><?php echo get_the_title(); ?></h3> 
        <?php echo wp_strip_all_tags(get_the_content());?> 
       </div> 
       <span><b>More...</b></span> 
      </a> 
     </div> 
    <?php endwhile; ?> 
<?php endif; ?> 

私はいくつかの追加機能を作成する必要がありますか?

答えて

0

だけの巣機能...

<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?> 
     <div class="news-el"> 
      <a href="<?php the_permalink(); ?>"> 
       <div class="news-content">      
        <h3><?php echo get_the_title(); ?></h3> 
        <?php echo wp_trim_words(wp_strip_all_tags(get_the_content(), 55));?> 
       </div> 
      </a> 
     </div> 
    <?php endwhile; ?> 
<?php endif; ?> 

機能が出力されます「...」55ワードのテキストブロックの最後に、この例では、あなたが本当にspanタグを必要としないので、 。トリミングされた単語の後ろに何を表示するかについては、wp_trim_words関数の3番目のパラメーターを指定してカスタマイズできます。

関連する問題