{"id":2390,"date":"2012-08-25T02:10:06","date_gmt":"2012-08-25T02:10:06","guid":{"rendered":"http:\/\/www.dognmonkey.com\/techs\/?p=2390"},"modified":"2012-09-01T09:10:41","modified_gmt":"2012-09-01T09:10:41","slug":"add-excerpts-to-wordpress-main-page","status":"publish","type":"post","link":"https:\/\/www.dognmonkey.com\/techs\/add-excerpts-to-wordpress-main-page.html","title":{"rendered":"Add Excerpts To WordPress Main Page"},"content":{"rendered":"<p style=\"text-align: center;\"><em>I like mono-lab themes, but none of them has excerpts built-in to list posts with excerpts on the main blog page. I found some codes that actually will work with any themes that don&#8217;t have excerpts functions at all. WordPress has built-in excerpts function, but the theme has to call it out to use.<\/em><\/p>\n<p style=\"text-align: center;\"><em>Depends upon the theme you use, on mono-lab piano-black and flat, 2 files that need to add codes to are function.php and index.php.<\/em><\/p>\n<p style=\"text-align: center;\"><em><a class=\"preview\" title=\"add codes to functionphp\" href=\"\/media\/wpweb\/themes\/functionphp.png\" rel=\"lightbox[excer]\">Function.php codes<\/a>: add these line any where in the function.php. Change the return # to the maximum characters we want to display, I set mine to 100 characters.<br \/>\n<\/em><\/p>\n<blockquote><p><em><code>function trim_excerpt($text) {<br \/>\nglobal $post;<br \/>\nreturn str_replace('[...]', '&lt;a href=\"'. get_permalink($post-&gt;ID) . '\"&gt;' . '...' . __('Read More', 'flat') . '' . '&lt;\/a&gt;', $text);<br \/>\n}<br \/>\nadd_filter('get_the_excerpt', 'trim_excerpt');<\/code><\/em><\/p>\n<p><em>function custom_excerpt_length( $length ) {<\/em><br \/>\n<em> return 100;<\/em><br \/>\n<em> }<\/em><br \/>\n<em> add_filter( &#8216;excerpt_length&#8217;, &#8216;custom_excerpt_length&#8217;, 999 );<\/em><\/p><\/blockquote>\n<p style=\"text-align: center;\"><em><a class=\"preview\" title=\"add codes to indexphp\" href=\"\/media\/wpweb\/themes\/indexphp.png\" rel=\"lightbox[excer]\">Index.php, Search.php, Archive.php codes:<\/a> add these lines to replace the post codes between &#8220;post_content&#8221; and &#8220;wp_link_page&#8221;<\/em><\/p>\n<blockquote><p><em><code>&lt;div class=\"post_content\"&gt;<br \/>\n&lt;?php if (trim_excerpt('$text')){<br \/>\nthe_excerpt();<br \/>\n} else {<br \/>\nthe_content(__('Read more', 'flat'));<br \/>\n}?&gt;<br \/>\n&lt;?php wp_link_pages(); ?&gt;<\/code><\/em><\/p><\/blockquote>\n<p style=\"text-align: center;\"><em>I added these codes to get excerpts on my main page of <a class=\"ib2 fancybox.iframe\" title=\"mono-lab downloads\" href=\"\/\/www.mono-lab.net\/download\/\">Flat theme from mono-lab<\/a><\/em><\/p>\n<ul class=\"lcp_catlist\" id=\"lcp_instance_0\"><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I like mono-lab themes, but none of them has excerpts built-in to list posts with excerpts on the main blog page. I found some codes that actually will work with any themes that don&#8217;t have excerpts functions at all. WordPress has built-in excerpts function, but the theme has to call it out to use. Depends <a href=\"https:\/\/www.dognmonkey.com\/techs\/add-excerpts-to-wordpress-main-page.html\" class=\"more-link\">&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,20],"tags":[217,185,812],"class_list":["post-2390","post","type-post","status-publish","format-standard","hentry","category-themes","category-wordpress","tag-excerpts","tag-themes-2","tag-wordpress"],"views":1171,"_links":{"self":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts\/2390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/comments?post=2390"}],"version-history":[{"count":14,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts\/2390\/revisions"}],"predecessor-version":[{"id":2400,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts\/2390\/revisions\/2400"}],"wp:attachment":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/media?parent=2390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/categories?post=2390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/tags?post=2390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}