php - Limit length post wordpress -


hi have site in wordpress , want limit character of preview post different default example obnly 5 characters.

this piece of content-category.php

<div class="entry-content">     <?php      $excerpt = get_the_excerpt();     if ( $use_excerpt == 'content' ) {         the_content('<a style="margin-left: 5px;text-transform: uppercase;display: inline-block;" href="'. get_permalink($post->id) . '"> '. __( 'leggi tutto' , 'color-theme-framework' ) .'</a>',true,'');     }        else if ( $use_excerpt == 'excerpt' && $excerpt != '' ){       the_excerpt('',false,'');       echo '<a style="margin-left: 5px;display: inline-block;" href="' . get_permalink($post->id) . '">' . __('leggi tutto', 'color-theme-framework') . '</a>';     } ?> </div><!-- entry-content --> 

and piece of functions.php of excerpt have read function limit character don't have understand how change return 5 characters intothe content preview of news example

/*=======================================     content width , excerpt redeclared =======================================*/ if ( !isset( $content_width ) )      $content_width = 980;  // remove rel attribute category list function remove_category_list_rel($output) {   $output = str_replace(' rel="category"', '', $output);   return $output; }  add_filter('wp_list_categories', 'remove_category_list_rel'); add_filter('the_category', 'remove_category_list_rel');  remove_action( 'wp_head', 'feed_links_extra', 3 );  remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'rsd_link' ); remove_action( 'wp_head', 'wlwmanifest_link' ); remove_action( 'wp_head', 'index_rel_link' ); remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );  remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); remove_action( 'wp_head', 'wp_generator' );  add_theme_support( 'automatic-feed-links' );  function new_excerpt_length($length) {     return 30; } add_filter('excerpt_length', 'new_excerpt_length');   function new_excerpt_more($more) {     return '...'; } add_filter('excerpt_more', 'new_excerpt_more'); 

how can ilimit character of preview of news 5 characters?

your code using

function new_excerpt_length($length) {     return 30; } add_filter('excerpt_length', 'new_excerpt_length'); 

the above code limit excerpt number of words , not characters.

i found this answer wordpress stackexchange has code limit number of characters.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -