<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>ThemeShaper Forums Topic: using more tags preferentially with excerpt fallback</title>
<link>http://themeshaper.com/forums/</link>
<description>Help In Shaping WordPress Themes</description>
<language>en</language>
<pubDate>Tue, 21 May 2013 14:50:59 +0000</pubDate>

<item>
<title>D.Lo on "using more tags preferentially with excerpt fallback"</title>
<link>http://themeshaper.com/forums/topic/using-more-tags-preferentially-with-excerpt-fallback#post-23658</link>
<pubDate>Mon, 31 Oct 2011 16:23:16 +0000</pubDate>
<dc:creator>D.Lo</dc:creator>
<guid isPermaLink="false">23658@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;I found this incredibly helpful and wanted to give you props.  I've looked through the forum for days and this code ended up being the basis for how I customized my child theme.  The result is home/category pages that show the teaser (i.e. up to the more tag if present), and then an automatic excerpt if there is no teaser.  I also added a second customization to replace the ellipsis after an auto-excerpt with a &#34;read more&#34; link.&#60;/p&#62;
&#60;p&#62;Here's my code in functions.php&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
&#38;lt;?php //Automatic use of teaser or excerpt for home/category pages.  Logic from &#60;a href=&#34;http://themeshaper.com/forums/topic/using-more-tags-preferentially-with-excerpt-fallback&#34; rel=&#34;nofollow&#34;&#62;http://themeshaper.com/forums/topic/using-more-tags-preferentially-with-excerpt-fallback&#60;/a&#62;&#60;br /&#62;
    function childtheme_excerpts($content) { //normally i'd call $post here as that is what thematic uses,  but that caused problems with the next line&#60;br /&#62;
        global $thematic_content_length, $post; //needed to declare the standard $post object&#60;br /&#62;
        if (is_home() &#124;&#124; is_front_page()&#124;&#124; is_category()) {&#60;br /&#62;
            if ( preg_match('/&#38;lt;!--more(.*?)?--&#38;gt;/', $post-&#38;gt;post_content ) ) {  //here's where i needed to the $post object. didn't seem to work at all with get_the_content()&#60;br /&#62;
                        $content = get_the_content(more_text());&#60;br /&#62;
                        $content = apply_filters('the_content', $content);&#60;br /&#62;
                        $content = str_replace(']]&#38;gt;', ']]&#38;gt;', $content);&#60;/p&#62;
&#60;p&#62;                } else {&#60;br /&#62;
                        $content = '';&#60;br /&#62;
                        $content .= get_the_excerpt();&#60;br /&#62;
                        $content = apply_filters('the_excerpt',$content);&#60;br /&#62;
                }&#60;br /&#62;
        }&#60;br /&#62;
        return $content; //send it back to the function. by using $content here i don't monkey with the $post object which was breaking the 'excerpt' and 'full' types. thematic_post will take this variable as the $post variable there and all will be well (as far as i can tell)&#60;br /&#62;
    }&#60;br /&#62;
    add_filter('thematic_post', 'childtheme_excerpts');&#60;br /&#62;
?&#38;gt;&#60;br /&#62;
&#38;lt;?php //If the WordPress automatic &#34;excerpt&#34; is displayed, replace the elipsis with a Read More link&#60;br /&#62;
   function excerpt_ellipse($text) {&#60;br /&#62;
       return str_replace('[...]', '...&#38;lt;p&#38;gt;&#60;a href=&#34;'.get_permalink().'&#34;&#62;Read More »&#60;/a&#62;&#38;lt;/p&#38;gt;', $text); }&#60;br /&#62;
    add_filter('get_the_excerpt', 'excerpt_ellipse');&#60;br /&#62;
?&#38;gt;&#60;br /&#62;
&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Thanks for putting this out there Helga!
&#60;/p&#62;</description>
</item>
<item>
<title>helgatheviking on "using more tags preferentially with excerpt fallback"</title>
<link>http://themeshaper.com/forums/topic/using-more-tags-preferentially-with-excerpt-fallback#post-19999</link>
<pubDate>Sat, 26 Mar 2011 09:13:31 +0000</pubDate>
<dc:creator>helgatheviking</dc:creator>
<guid isPermaLink="false">19999@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;solved this for anyone who cares to know.  the first part above is correct... you must filter thematic_content and tell it where to use this new &#34;type&#34;.  and now to filter thematic_post&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function childtheme_excerpts($content) { //normally i&#38;#39;d call $post here as that is what thematic uses,  but that caused problems with the next line
	global $thematic_content_length, $post; //needed to declare the standard $post object

		if ( strtolower($thematic_content_length) == &#38;#39;more&#38;#39; ) {

			if ( preg_match(&#38;#39;/&#38;lt;!--more(.*?)?--&#38;gt;/&#38;#39;, $post-&#38;gt;post_content ) ) {  //here&#38;#39;s where i needed to the $post object. didn&#38;#39;t seem to work at all with get_the_content()
				$content = get_the_content(more_text());
				$content = apply_filters(&#38;#39;the_content&#38;#39;, $content);
				$content = str_replace(&#38;#39;]]&#38;gt;&#38;#39;, &#38;#39;]]&#38;gt;&#38;#39;, $content);

			} else {
				$content = &#38;#39;&#38;#39;;
				$content .= get_the_excerpt();
				$content = apply_filters(&#38;#39;the_excerpt&#38;#39;,$content);
				if ( apply_filters( &#38;#39;thematic_post_thumbs&#38;#39;, TRUE) ) {
					$content_title = get_the_title();
					$size = apply_filters( &#38;#39;thematic_post_thumb_size&#38;#39; , array(100,100) );
					$attr = apply_filters( &#38;#39;thematic_post_thumb_attr&#38;#39;, array(&#38;#39;title&#38;#39;	=&#38;gt; &#38;#39;Permalink to &#38;#39; . $post_title) );
					if ( has_post_thumbnail() ) {
						$content = &#38;#39;&#38;lt;a class=&#38;quot;entry-thumb&#38;quot; href=&#38;quot;&#38;#39; . get_permalink() . &#38;#39;&#38;quot; title=&#38;quot;Permalink to &#38;#39; . get_the_title() . &#38;#39;&#38;quot; &#38;gt;&#38;#39; . get_the_post_thumbnail(get_the_ID(), $size, $attr) . &#38;#39;&#38;lt;/a&#38;gt;&#38;#39; . $content;
					}
				}
			}

		} 

	return $content; //send it back to the function. by using $content here i don&#38;#39;t monkey with the $post object which was breaking the &#38;#39;excerpt&#38;#39; and &#38;#39;full&#38;#39; types. thematic_post will take this variable as the $post variable there and all will be well (as far as i can tell)

}

add_filter(&#38;#39;thematic_post&#38;#39;, &#38;#39;childtheme_excerpts&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;i've tweaked it out a little for my own needs, but the above is the heart of what i was going for.  if there is a more tag present it will display the full content up to said tag... if there is no more tag it will present the standard thematic excerpt.  &#60;/p&#62;
&#60;p&#62;enjoy!
&#60;/p&#62;</description>
</item>
<item>
<title>helgatheviking on "using more tags preferentially with excerpt fallback"</title>
<link>http://themeshaper.com/forums/topic/using-more-tags-preferentially-with-excerpt-fallback#post-19818</link>
<pubDate>Thu, 17 Mar 2011 21:46:01 +0000</pubDate>
<dc:creator>helgatheviking</dc:creator>
<guid isPermaLink="false">19818@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;thematic_content defines the way that full content pages and excerpts look in thematic.  has anybody ever created a different type?  i've done that before, but this time i am specifically looking to create a type that first looks for full content before a &#38;lt;more&#38;gt; tag and then failing that autogenerate an excerpt.  any thoughts?&#60;/p&#62;
&#60;p&#62;so for example, i'd first define that i want to use this new 'type' on category pages&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function childtheme_content($content) {
	if (is_category()) {
		$content= &#38;#39;more&#38;#39;;
	}
	return $content;
}

add_filter(&#38;#39;thematic_content&#38;#39;, &#38;#39;childtheme_content&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and then hypothetically something like&#60;/p&#62;
&#60;p&#62;`&#60;br /&#62;
function childtheme_more($post){&#60;/p&#62;
&#60;p&#62;/* if (has &#38;lt;!--more--&#38;gt; tag) {&#60;br /&#62;
           $post = content up until more tag;&#60;br /&#62;
   } else {&#60;br /&#62;
           $post = get_the_excerpt();&#60;br /&#62;
   }&#60;br /&#62;
*/&#60;/p&#62;
&#60;p&#62;return $post;&#60;br /&#62;
}&#60;br /&#62;
add_filter('thematic_content','childtheme_more');
&#60;/p&#62;</description>
</item>

</channel>
</rss>
