Changing the Excerpt Length on a WordPress Blog

By . Category: Wordpress Tags:

irnanto.comChanging the length of excerpt on a wordpress blog that aims to shorten or lengthen the amount of words that will be displayed on a wordpress blog and is usually used on the home page or search. By default, wordpress using or setting up default excerpt function with a word length of 55 (fifty-five) words. If you want to change, can be changed by adding a bit of source code in the file functions.php. Source code to change the excerpt length on wordpress as below.

function custom_excerpt_length($length){
    return 20;

add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );

Explanation of source code above is the first line makes the function with a parameter, and the second line is the return of the data (20 indicates the number of words will appear), the third line is the addition or filtering of the hook (excerpt_length) with a filter function that uses function custom_excerpt_length, and 999 is the priority setting. Save a result of adding the source code, and the results can be viewed directly on the home page or search page.

Each of the words on the post that is displayed will be adjusted to the length or the number of words from the setting excerpt_length. This technique is widely used to customize the appearance of the text with the layout of the template that is used to match the desired look of the designer template itself or from the developer blog.

Ok, tricks on Changing the excerpt length on wordpress blog, I hope the above explanation can be understood and applied properly. good luck


No comments yet untuk “Changing the Excerpt Length on a WordPress Blog”

Tinggalkan Komentar