pobranie treści wpisu w określonej ilości znaków
1234567890123456789 123456789
<?php echo substr(get_the_excerpt(), 0,30); ?>
function get_excerpt(){
$excerpt = get_the_content();
$excerpt = preg_replace(” (\[.*?\])”,”,$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, 10);
$excerpt = substr($excerpt, 0, strripos($excerpt, ” „));
$excerpt = trim(preg_replace( '/\s+/’, ’ ’, $excerpt));
$excerpt = $excerpt.’… <a href=”’.$permalink.'”>more</a>’;
return $excerpt;
}
<?php echo get_excerpt(); ?>
function excerpt($limit) {
$excerpt = explode(’ ’, get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(” „,$excerpt).’…’;
} else {
$excerpt = implode(” „,$excerpt);
}
$excerpt = preg_replace(’`\[[^\]]*\]`’,”,$excerpt);
return $excerpt;
}
function content($limit) {
$content = explode(’ ’, get_the_content(), $limit);
if (count($content)>=$limit) {
array_pop($content);
$content = implode(” „,$content).’…’;
} else {
$content = implode(” „,$content);
}
$content = preg_replace(’/\[.+\]/’,”, $content);
$content = apply_filters(’the_content’, $content);
$content = str_replace(’]]>’, ’]]>’, $content);
return $content;
}
<?php echo excerpt(2); ?>
Hope this helps and happy coding :)
Zobacz jeszcze
wyswietlenie ograniczonej liczby słów postu
<?php echo limit_words(get_the_excerpt(), '25'); echo(' ');...