E
E
Endru2015-06-15 15:07:23
CMS
Endru, 2015-06-15 15:07:23

Wordpress how to display announcement with character limit?

I'm outputting now like this, tell me how to limit the output of a short announcement to 70 characters, for example.

<ul class="news-text">
<?php
$id=5; // ID заданной рубрики
$n=2;   // количество выводимых записей
$recent = new WP_Query("cat=$id&showposts=$n"); 
while($recent->have_posts()) : $recent->the_post();
?>

<li>
   <header>
   <div class="row">
<div class="text-left news-title"><a href="<?php the_permalink() ?>" rel="bookmark"> <h2><?php the_title(); ?></h2>  </a> </div>
       <div class="text-right">
           <span class="news-date"><i class="fa-calendar fa"></i>    <?php the_date('Y-m-d'); ?></span></div>
       </div>
</header>
  <div class="row"> 
   <div class="news-content">
    <?php 
global $more;    // Объявим переменную $more как глобальную (перед Циклом WordPress).
$more = 0;       // Изменим значение переменной, чтобы показать только текст до тега more.
the_content("Далее...");
?>    
       
    </div></div>     
    
</li>
  <hr />
<?php endwhile; ?>
</ul>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2015-06-15
@llgruff

Announcements of articles on WordPress. The more and the_excerpt tags are links .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question