<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to Prevent Post Titles Wrapping When Using Thesis Teasers</title>
	<atom:link href="http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70</link>
	<description>WordPress Hints, Tips and Tutorials for getting the most from Wordpress</description>
	<lastBuildDate>Wed, 25 Jan 2012 15:26:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Anthony</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-687</link>
		<dc:creator>Anthony</dc:creator>
		<pubDate>Fri, 14 Jan 2011 21:07:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-687</guid>
		<description>This script didn&#039;t work for me. And I&#039;m not much of a coder, so I can&#039;t interpret any of this.

Is there anything else that needs to be done? Or do I simply copy and paste this into custom_functions.php?</description>
		<content:encoded><![CDATA[<p>This script didn&#8217;t work for me. And I&#8217;m not much of a coder, so I can&#8217;t interpret any of this.</p>
<p>Is there anything else that needs to be done? Or do I simply copy and paste this into custom_functions.php?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucifr</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-571</link>
		<dc:creator>Lucifr</dc:creator>
		<pubDate>Tue, 28 Dec 2010 12:03:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-571</guid>
		<description>Thank you! I&#039;ll try this later. I&#039;m thinking about leaning some jQuery.</description>
		<content:encoded><![CDATA[<p>Thank you! I&#8217;ll try this later. I&#8217;m thinking about leaning some jQuery.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russell</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-570</link>
		<dc:creator>Russell</dc:creator>
		<pubDate>Tue, 28 Dec 2010 11:26:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-570</guid>
		<description>Hi,

Unfortunately my solution is based on number of characters rather than width. 

I can refer you to the previous comment where you could fix the width of the headline and use the CSS overflow: hidden; However, this would truncate the headline abruptly so it would most likely not give you the results you are looking for.

A more interesting solution would be to add a custom field to each post called teaser_headline and make sure that these manually added short headlines make sense to the reader and are also short enough to fit. It would not be too difficult to place the short headline in a hidden element (using the thesis_hook_before_headline hook) and then use jQuery to swap the longer headline for the shorter one. This would give the desired effect of perfect layout and perfect headlines. 

Regards

Russell</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Unfortunately my solution is based on number of characters rather than width. </p>
<p>I can refer you to the previous comment where you could fix the width of the headline and use the CSS overflow: hidden; However, this would truncate the headline abruptly so it would most likely not give you the results you are looking for.</p>
<p>A more interesting solution would be to add a custom field to each post called teaser_headline and make sure that these manually added short headlines make sense to the reader and are also short enough to fit. It would not be too difficult to place the short headline in a hidden element (using the thesis_hook_before_headline hook) and then use jQuery to swap the longer headline for the shorter one. This would give the desired effect of perfect layout and perfect headlines. </p>
<p>Regards</p>
<p>Russell</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucifr</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-560</link>
		<dc:creator>Lucifr</dc:creator>
		<pubDate>Mon, 27 Dec 2010 15:47:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-560</guid>
		<description>Hi Russell, 

Thank u for your solution. I have a question hope u could answer me. 

I&#039;m running a blog in chinese. It seems that the title won&#039;t get shortened correctly when combined chinese characters and english. Is there a solution to this? Thank u!</description>
		<content:encoded><![CDATA[<p>Hi Russell, </p>
<p>Thank u for your solution. I have a question hope u could answer me. </p>
<p>I&#8217;m running a blog in chinese. It seems that the title won&#8217;t get shortened correctly when combined chinese characters and english. Is there a solution to this? Thank u!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russell</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-394</link>
		<dc:creator>Russell</dc:creator>
		<pubDate>Fri, 26 Nov 2010 19:56:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-394</guid>
		<description>Hi Sean,

What you are striving for may indeed be possible, but you need to be using jQuery (the language of the browser) rather than PHP (the language of the server).

If you know the id of the HTML element you want to control than you can use the jQuery width function to set the desired width and and set the overflow-x attribute to hidden. Check out http://api.jquery.com/width/ and http://www.css3.com/css-overflow-x/</description>
		<content:encoded><![CDATA[<p>Hi Sean,</p>
<p>What you are striving for may indeed be possible, but you need to be using jQuery (the language of the browser) rather than PHP (the language of the server).</p>
<p>If you know the id of the HTML element you want to control than you can use the jQuery width function to set the desired width and and set the overflow-x attribute to hidden. Check out <a href="http://api.jquery.com/width/" rel="nofollow">http://api.jquery.com/width/</a> and <a href="http://www.css3.com/css-overflow-x/" rel="nofollow">http://www.css3.com/css-overflow-x/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-393</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Fri, 26 Nov 2010 18:07:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-393</guid>
		<description>That makes sense. I actually inserted the code right into my post.php file, since, as you point out, there is no hook at the necessary location. A function could be created for better portability, I suppose, but that would still require a new hook being written into the appropriate pages.

&lt;?php echo substr($post-&gt;post_title,0,20); if ((strlen($post-&gt;post_title)&gt;20) &amp;&amp; is_home()) { echo &quot;...&quot;; } ?&gt;

Let&#039;s see if that comes through. Basically, it uses the PHP function, substr(), to pull the first 20 characters out of the string, which is itself pulled from the $post array. Then it checks if the title was long enough to worry about with the PHP function, strlen(), and also checks if it is the home page or not, since the whole title should be displayed on single pages or archives. The ellipsis is slapped onto the end of the string without ceremony, provided the original string was greater than 20 characters long. A more detail-oriented solution would delete the final character if it is a space, but I&#039;m not going to bother with that at this time.

What I was really hoping for was a solution that would be aware of the containing div and would truncate the string as needed based on the size of the div, regardless of the number of characters. But I&#039;m not sure if that&#039;s even possible. 

Cheers!</description>
		<content:encoded><![CDATA[<p>That makes sense. I actually inserted the code right into my post.php file, since, as you point out, there is no hook at the necessary location. A function could be created for better portability, I suppose, but that would still require a new hook being written into the appropriate pages.</p>
<p>&lt;?php echo substr($post-&gt;post_title,0,20); if ((strlen($post-&gt;post_title)&gt;20) &amp;&amp; is_home()) { echo &#8220;&#8230;&#8221;; } ?&gt;</p>
<p>Let&#8217;s see if that comes through. Basically, it uses the PHP function, substr(), to pull the first 20 characters out of the string, which is itself pulled from the $post array. Then it checks if the title was long enough to worry about with the PHP function, strlen(), and also checks if it is the home page or not, since the whole title should be displayed on single pages or archives. The ellipsis is slapped onto the end of the string without ceremony, provided the original string was greater than 20 characters long. A more detail-oriented solution would delete the final character if it is a space, but I&#8217;m not going to bother with that at this time.</p>
<p>What I was really hoping for was a solution that would be aware of the containing div and would truncate the string as needed based on the size of the div, regardless of the number of characters. But I&#8217;m not sure if that&#8217;s even possible. </p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russell</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-392</link>
		<dc:creator>Russell</dc:creator>
		<pubDate>Fri, 26 Nov 2010 12:29:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-392</guid>
		<description>Hi Sean,

The truncation is done in javascript as there is not a suitable hook in Thesis to perform the more efficient PHP title truncation that you suggest.

You are correct about the proportional fonts hence that is why I decide to use of a conservative truncation size of 40 to allow for a few capital &#039;W&#039;s in the title.

Your second comment which I presume had some code got mangled by wordpress and came through as blank so please resubmit, maybe replacing the openign angle bracket by an ampersand (&amp;)lt; minus the brackets.</description>
		<content:encoded><![CDATA[<p>Hi Sean,</p>
<p>The truncation is done in javascript as there is not a suitable hook in Thesis to perform the more efficient PHP title truncation that you suggest.</p>
<p>You are correct about the proportional fonts hence that is why I decide to use of a conservative truncation size of 40 to allow for a few capital &#8216;W&#8217;s in the title.</p>
<p>Your second comment which I presume had some code got mangled by wordpress and came through as blank so please resubmit, maybe replacing the openign angle bracket by an ampersand (&amp;)lt; minus the brackets.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-389</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Fri, 26 Nov 2010 01:22:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-389</guid>
		<description>Does this simply truncate the string to 40 characters? The reason I ask is that, with proportional fonts, the optimal number of characters would vary from one sentence to the next, wouldn&#039;t it? A title heavy on capital &quot;W&quot;s and &quot;X&quot;s would become too long with fewer characters than a sentence with a lot of lower case &quot;i&quot;s, for example.

And if it is a fixed length truncation, wouldn&#039;t something like
post_title,0,40); if (strlen($post-&gt;post_title)&gt;40) { echo &quot;...&quot;; } ?&gt;
be more efficient?</description>
		<content:encoded><![CDATA[<p>Does this simply truncate the string to 40 characters? The reason I ask is that, with proportional fonts, the optimal number of characters would vary from one sentence to the next, wouldn&#8217;t it? A title heavy on capital &#8220;W&#8221;s and &#8220;X&#8221;s would become too long with fewer characters than a sentence with a lot of lower case &#8220;i&#8221;s, for example.</p>
<p>And if it is a fixed length truncation, wouldn&#8217;t something like<br />
post_title,0,40); if (strlen($post-&gt;post_title)&gt;40) { echo &#8220;&#8230;&#8221;; } ?&gt;<br />
be more efficient?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russell</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-137</link>
		<dc:creator>Russell</dc:creator>
		<pubDate>Sun, 09 May 2010 13:19:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-137</guid>
		<description>Hi Erik,

A couple of suggestions: firstly try replacing the $ by jQuery - this gets around potential conflicts with other javascript libraries; and secondly, I think the replaceWith will be applied to the first anchor link on the page which is not correct; the replace_title PHP routine needs to get the title from the custom field using the $post variable and then yse jQuery that applies the replacement to each teaser title. Something like
[js]
function replace_title () {
global $post;
$post_id = $post-&gt;ID; 
$new_title =  get_post_custom_values(&#039;my_new_title&#039;, $post_id); 
?&gt;
&lt;script type=&quot;text/javascript&quot;&gt; 
     jQuery(document).ready( function () {
          jQuery(&#039;div .post-&lt;?php echo $post_id;?&gt; .teaser h2.entry-title a&#039;).html(&quot;&lt;?php echo $new_title; ?&gt;&quot;);
          });
&lt;/script&gt;
&lt;?php
}
[/js]
I have not checked this but I think it is closer.</description>
		<content:encoded><![CDATA[<p>Hi Erik,</p>
<p>A couple of suggestions: firstly try replacing the $ by jQuery &#8211; this gets around potential conflicts with other javascript libraries; and secondly, I think the replaceWith will be applied to the first anchor link on the page which is not correct; the replace_title PHP routine needs to get the title from the custom field using the $post variable and then yse jQuery that applies the replacement to each teaser title. Something like</p>
<pre class="brush: jscript; title: ; notranslate">
function replace_title () {
global $post;
$post_id = $post-&gt;ID;
$new_title =  get_post_custom_values('my_new_title', $post_id);
?&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
     jQuery(document).ready( function () {
          jQuery('div .post-&lt;?php echo $post_id;?&gt; .teaser h2.entry-title a').html(&quot;&lt;?php echo $new_title; ?&gt;&quot;);
          });
&lt;/script&gt;
&lt;?php
}
</pre>
<p>I have not checked this but I think it is closer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://www.wordpresswise.com/how-to-prevent-post-titles-wrapping-when-using-thesis-teasers-70/comment-page-1#comment-136</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Sat, 08 May 2010 22:04:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.wordpresswise.com/?p=70#comment-136</guid>
		<description>Hi Russel,

So I made an attempt to get this going, Im not sure why this is not working, 

add_action (&#039;thesis_hook_after_teaser_headline&#039;,&#039;replace_title&#039;);  // replace the teaser title
function replace_title () {
?&gt;



$(document).ready(function() {
   $(&#039;a&#039;).replaceWith(&#039;
&lt;a href=&quot;some.htm&quot; rel=&quot;nofollow&quot;&gt;I have been replaced&lt;/a&gt;
&#039;);
});


&lt;?php
}</description>
		<content:encoded><![CDATA[<p>Hi Russel,</p>
<p>So I made an attempt to get this going, Im not sure why this is not working, </p>
<p>add_action (&#8216;thesis_hook_after_teaser_headline&#8217;,'replace_title&#8217;);  // replace the teaser title<br />
function replace_title () {<br />
?&gt;</p>
<p>$(document).ready(function() {<br />
   $(&#8216;a&#8217;).replaceWith(&#8216;<br />
<a href="some.htm" rel="nofollow">I have been replaced</a><br />
&#8216;);<br />
});</p>
<p>&lt;?php<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

