Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question