I need to change the character/word limit of manual excerpts which will be displayed on recent posts slider. I think it's 55 characters right now without counting spaces and punctuation marks. Am i right? I researched and accordingly tried to add some codes on functions.php
but none of them worked. I thought they were out of date or unrelated. I also edited the following code in recent-posts-slider.php
but didn't work:
$excerpt_length = 100;
Besides, how many words that recent posts slider shows isn't consistent anyway. It displays 10-15 words for a post then it displays properly 50 words for another.
What should i do?
You're right, i'm sorry. I'm just doing what i saw from some articles. I really don't know much about coding.
My 'recent posts slider' is a function that comes with the theme i use, called 'Big City'. So in themes/bigcity direction there is a recent-posts-slider.php file. I can set a 50 words limit for automated excerpts via wp-admin but couldn't set one for manuals.
I won't use excerpts in homepage, i just want those excerpts displayed in the slider. These are some codes about excerpts in recent-posts-slider.php :
$excerpt_length = '';
$excerpt_length = abs( (($width-40)/20) * (($height-55)/15) );
/*if ( ($width) > $height)
$excerpt_length = $excerpt_length - (($excerpt_length * 5) /100);
else
$excerpt_length = $excerpt_length - (($excerpt_length * 30) /100);*/
function create_excerpt( $post_content, $excerpt_length, $post_permalink, $excerpt_words=NULL){
$post_excerpt = strip_shortcodes($post_content);
$post_excerpt = str_replace(']]>', ']]>', $post_excerpt);
$post_excerpt = strip_tags($post_excerpt);
$read_more = get_option_tree('blog_read', '');
if( !empty($excerpt_words) ){
if ( !empty($post_excerpt) ) {
$words = explode(' ', $post_excerpt, $excerpt_words );
array_pop($words);
if($read_more){
array_push($words, ' <a href="'.$post_permalink.'">'.$read_more.'</a>');
}
else{
array_push($words, ' <a href="'.$post_permalink.'"></a>');
}
$post_excerpt_rps = implode(' ', $words);
return $post_excerpt_rps;
} else {
return;
}
}else{
$post_excerpt_rps = substr( $post_excerpt, 0, $excerpt_length );
if ( !empty($post_excerpt_rps) ) {
if ( strlen($post_excerpt) > strlen($post_excerpt_rps) ){
$post_excerpt_rps =substr( $post_excerpt_rps, 0, strrpos($post_excerpt_rps,' '));
}
$words = explode(' ', $post_excerpt, $excerpt_words );
array_pop($words);
if($read_more){
array_push($words, ' <a href="'.$post_permalink.'">'.$read_more.'</a>');
}
else{
array_push($words, ' <a href="'.$post_permalink.'"></a>');
}
return $post_excerpt_rps;
} else {
return;
}
}
}
recent-posts-slider.php
? What does the code do with$excerpt_length
exactly? Without more context this is like trying to get help with an algebra problem by asking, "If x=100, how do I solve the equation?" Well, what is the equation?