{"id":11202,"date":"2012-05-09T22:23:43","date_gmt":"2012-05-09T20:23:43","guid":{"rendered":"https:\/\/www.saasweb.agency\/blog\/wordpress-designing-custom-templates-individual-lengths-for-article-excerpts\/"},"modified":"2026-10-27T08:16:13","modified_gmt":"2026-10-27T07:16:13","slug":"wordpress-designing-custom-templates-individual-lengths-for-article-excerpts","status":"publish","type":"post","link":"https:\/\/www.saasweb.agency\/en\/blog\/wordpress-designing-custom-templates-individual-lengths-for-article-excerpts\/","title":{"rendered":"WordPress, Designing Custom Templates: Individual Lengths for Article Excerpts"},"content":{"rendered":"<p>On the article page (index), one might want to adjust the length of the excerpt. However, on another page, one might also desire a preview\u2014for instance, the 3 latest posts\u2014with a more concise version of the article excerpt. <\/p>\n<p>For the first scenario, only this entry in `functions.php` is required:<\/p>\n<pre class=\"wp-block-code\"><code>function custom_excerpt_length( $length ) {\n  \/\/ Standard ist 54\n  return 40;  \n}\nadd_filter( 'excerpt_length', 'custom_excerpt_length', 999 );<\/code><\/pre>\n<p>Problem: This sets all excerpts to 40 words in length.<\/p>\n<p>To differentiate, for example, based on the page being visited, one can simply query the page within the function.<\/p>\n<pre class=\"wp-block-code\"><code>function custom_excerpt_length( $length ) {\n\n  \/\/ Home ist index\n  if( is_home() ){\n    return 40;\n  }else{\n    return 10;\n  }\n}\n\nadd_filter( 'excerpt_length', 'custom_excerpt_length', 999 );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>On the article page (index), one might want to adjust the length of the excerpt. However, on another page, one might also desire a preview\u2014for instance, the 3 latest posts\u2014with a more concise version of the article excerpt. For the first scenario, only this entry in `functions.php` is required: function custom_excerpt_length( $length ) { \/\/ \u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[981,983],"tags":[1061,1282,1029,1218,1691,838,819],"class_list":["post-11202","post","type-post","status-publish","format-standard","hentry","category-programming","category-tutorial","tag-custom_excerpt_length","tag-custom-excerpt","tag-excerpt","tag-functions-php","tag-summary","tag-template","tag-wordpress"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/posts\/11202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/comments?post=11202"}],"version-history":[{"count":0,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/posts\/11202\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/media?parent=11202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/categories?post=11202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/tags?post=11202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}