2017-11-02 2 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 함수의 세 번째 매개 변수를 지정하여 사용자 정의 할 수 있습니다.