{"id":62027,"date":"2016-10-15T07:31:54","date_gmt":"2016-10-15T07:31:54","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=62027"},"modified":"2016-10-15T07:31:54","modified_gmt":"2016-10-15T07:31:54","slug":"multiple-excerpt-wordpress","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/","title":{"rendered":"Multiple Excerpt WordPress"},"content":{"rendered":"<p><strong>Excerpt<\/strong> is a short description of the post content. \u00a0To add excerpt in wordpress we use &#8221; the_excerpt( ) &#8221; &amp; it adds a little description of the post.<\/p>\n<p>But if we want to use different excerpt for different post types then we can approach like this :-<\/p>\n<pre class=\"brush:php\">&lt;?php \r\nfunction multiple_excerpt($more) \r\n{\r\n    global $post;\r\n\r\n    if($post-&gt;post_type == 'post-type-name')\r\n      return ' &lt;a class=\"main-color\" title=\"read more\" href=\"'. get_permalink() . '\"&gt; More Info...&lt;\/a&gt;';\r\n\r\n    return ' &lt;a class=\"main-color\" title=\"show more\" href=\"'. get_permalink() . '\"&gt;[...]&lt;\/a&gt;';\r\n}\r\n\r\nadd_filter('excerpt_more', 'multiple_excerpt');\r\n?&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>If we want to use excerpt of more content\u00a0on a post type ( i.e. post\u00a0) and less content on \u00a0some custom post type then we can also customise its length according to the post type.<\/p>\n<p>For this we can approach like this:-<\/p>\n<pre class=\"brush:php\">&lt;?php\r\nfunction new_excerpt_length($length) {\r\n  global $post;\r\n  if ($post-&gt;post_type == 'post')\r\n    return 50;\r\n  elseif ($post-&gt;post_type == 'post-type-name')\r\n    return 22;\r\n  else\r\n    return 26;\r\n  \r\n}\r\nadd_filter('excerpt_length', 'new_excerpt_length');\r\n?&gt;\r\n<\/pre>\n<div class=\"panel panel-primary\">\n<div class=\"panel-heading\">\n<div>\n<h3 class=\"panel-title\">Support<\/h3>\n<\/div>\n<\/div>\n<div class=\"panel-body\">\n<div>\n<p>Still have any issue feel free to add a ticket and let us know your views to make the code better\u00a0<a href=\"https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/\">https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/<\/a><\/p>\n<p>Thanks for Your Time! Have a Good Day!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Excerpt is a short description of the post content. \u00a0To add excerpt in wordpress we use &#8221; the_excerpt( ) &#8221; &amp; it adds a little description of the post. But if we want to use different excerpt for different post types then we can approach like this :- &lt;?php function multiple_excerpt($more) { global $post; if($post-&gt;post_type <a href=\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":111,"featured_media":62042,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1260],"tags":[3794,3792,3793,1258],"class_list":["post-62027","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-custom-excerpt","tag-excerpt","tag-multiple-excerpt","tag-wordpress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create Multiple Custom Excerpt with varing length in Wordpress<\/title>\n<meta name=\"description\" content=\"Creating multiple custom excerpt for different post types and its length can also be customised , different length of excerpt for different post types.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Multiple Custom Excerpt with varing length in Wordpress\" \/>\n<meta property=\"og:description\" content=\"Creating multiple custom excerpt for different post types and its length can also be customised , different length of excerpt for different post types.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-15T07:31:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ayush Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ayush Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/\"},\"author\":{\"name\":\"Ayush Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/5deb39718ae59fa5659a825549b7df4a\"},\"headline\":\"Multiple Excerpt WordPress\",\"datePublished\":\"2016-10-15T07:31:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/\"},\"wordCount\":132,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png\",\"keywords\":[\"Custom Excerpt\",\"Excerpt\",\"Multiple Excerpt\",\"wordpress\"],\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/\",\"url\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/\",\"name\":\"Create Multiple Custom Excerpt with varing length in Wordpress\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png\",\"datePublished\":\"2016-10-15T07:31:54+00:00\",\"description\":\"Creating multiple custom excerpt for different post types and its length can also be customised , different length of excerpt for different post types.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png\",\"width\":825,\"height\":260,\"caption\":\"Custom Post Type\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Multiple Excerpt WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/5deb39718ae59fa5659a825549b7df4a\",\"name\":\"Ayush Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3488792c5856a76629020ea17053d952aa9915d88309f1f38e901acce88408d2?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3488792c5856a76629020ea17053d952aa9915d88309f1f38e901acce88408d2?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ayush Singh\"},\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/ayush-singh265\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Multiple Custom Excerpt with varing length in Wordpress","description":"Creating multiple custom excerpt for different post types and its length can also be customised , different length of excerpt for different post types.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"Create Multiple Custom Excerpt with varing length in Wordpress","og_description":"Creating multiple custom excerpt for different post types and its length can also be customised , different length of excerpt for different post types.","og_url":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-10-15T07:31:54+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png","type":"image\/png"}],"author":"Ayush Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ayush Singh","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/"},"author":{"name":"Ayush Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/5deb39718ae59fa5659a825549b7df4a"},"headline":"Multiple Excerpt WordPress","datePublished":"2016-10-15T07:31:54+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/"},"wordCount":132,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png","keywords":["Custom Excerpt","Excerpt","Multiple Excerpt","wordpress"],"articleSection":["WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/","url":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/","name":"Create Multiple Custom Excerpt with varing length in Wordpress","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png","datePublished":"2016-10-15T07:31:54+00:00","description":"Creating multiple custom excerpt for different post types and its length can also be customised , different length of excerpt for different post types.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/10\/WordPress-Code-Snippet.png","width":825,"height":260,"caption":"Custom Post Type"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/multiple-excerpt-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Multiple Excerpt WordPress"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/5deb39718ae59fa5659a825549b7df4a","name":"Ayush Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3488792c5856a76629020ea17053d952aa9915d88309f1f38e901acce88408d2?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3488792c5856a76629020ea17053d952aa9915d88309f1f38e901acce88408d2?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ayush Singh"},"sameAs":["http:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/ayush-singh265\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/62027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=62027"}],"version-history":[{"count":17,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/62027\/revisions"}],"predecessor-version":[{"id":62048,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/62027\/revisions\/62048"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/62042"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=62027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=62027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=62027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}