<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WP Engineer &#187; wp2.9</title>
	<atom:link href="http://wpengineer.com/tag/wp2-9/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Sun, 22 Jan 2012 13:32:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Display Post Thumbnail Also In Edit Post and Page Overview</title>
		<link>http://wpengineer.com/1960/display-post-thumbnail-post-page-overview/</link>
		<comments>http://wpengineer.com/1960/display-post-thumbnail-post-page-overview/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 10:51:49 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Post Thumbnail]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1960</guid>
		<description><![CDATA[WordPress version 2.9 introduced the function of Post Thumbnail. We wrote about this feature in this post and here and also in many other blogs. I find it an advantage, if the overview of articles and pages also provides the associated thumbnail. Therefore, I would like to introduce a small code snippet that makes just [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress version 2.9 introduced the function of Post Thumbnail. We wrote about this feature <a href="http://wpengineer.com/about-wordpress-post-thumbnail/">in this post</a> and <a href="http://wpengineer.com/wordpress-2-9-add_theme_support-and-has_post_image/">here</a> and also in many other blogs. I find it an advantage, if the overview of articles and pages also provides the associated thumbnail. Therefore, I would like to introduce a small code snippet that makes just that.<br />
<span id="more-1960"></span></p>
<p><img src="http://wpengineer.com/wp-content/uploads/post-thumbnail-edit.png" alt="" title="post-thumbnail-edit" width="450" height="360" class="aligncenter size-full wp-image-1961" /></p>
<p>The above screenshot should illustrate what the little extension does. The following code must be put in a Plugin or be copied into the <code>functions.php</code> of the theme.</p>
<pre lang="php">
if ( !function_exists(&#039;fb_AddThumbColumn&#039;) &amp;&amp; function_exists(&#039;add_theme_support&#039;) ) {

	// for post and page
	add_theme_support(&#039;post-thumbnails&#039;, array( &#039;post&#039;, &#039;page&#039; ) );

	function fb_AddThumbColumn($cols) {

		$cols&#091;&#039;thumbnail&#039;&#093; = __(&#039;Thumbnail&#039;);

		return $cols;
	}

	function fb_AddThumbValue($column_name, $post_id) {

			$width = (int) 35;
			$height = (int) 35;

			if ( &#039;thumbnail&#039; == $column_name ) {
				// thumbnail of WP 2.9
				$thumbnail_id = get_post_meta( $post_id, &#039;_thumbnail_id&#039;, true );
				// image from gallery
				$attachments = get_children( array(&#039;post_parent&#039; =&gt; $post_id, &#039;post_type&#039; =&gt; &#039;attachment&#039;, &#039;post_mime_type&#039; =&gt; &#039;image&#039;) );
				if ($thumbnail_id)
					$thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true );
				elseif ($attachments) {
					foreach ( $attachments as $attachment_id =&gt; $attachment ) {
						$thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true );
					}
				}
					if ( isset($thumb) &amp;&amp; $thumb ) {
						echo $thumb;
					} else {
						echo __(&#039;None&#039;);
					}
			}
	}

	// for posts
	add_filter( &#039;manage_posts_columns&#039;, &#039;fb_AddThumbColumn&#039; );
	add_action( &#039;manage_posts_custom_column&#039;, &#039;fb_AddThumbValue&#039;, 10, 2 );

	// for pages
	add_filter( &#039;manage_pages_columns&#039;, &#039;fb_AddThumbColumn&#039; );
	add_action( &#039;manage_pages_custom_column&#039;, &#039;fb_AddThumbValue&#039;, 10, 2 );
}
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1960/display-post-thumbnail-post-page-overview/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>WordPress Widget-Areas with Description</title>
		<link>http://wpengineer.com/1871/wordpress-widget-areas-with-description/</link>
		<comments>http://wpengineer.com/1871/wordpress-widget-areas-with-description/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 07:12:09 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1871</guid>
		<description><![CDATA[Using WordPress version 2.9, there is now a possibility that we can write more detailed description for the widget areas. This is especially interesting when you define different widget areas, depending of categories or because the theme author defines various widget areas, that allows adjustments in more areas than just the sidebar. I do this [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-23.jpg" alt="" title="WordPress-Christmas-23" width="600" height="400" class="aligncenter size-full wp-image-1901" />Using WordPress version 2.9, there is now a possibility that we can write more detailed description for the widget areas. This is especially interesting when you define different widget areas, depending of categories or because the theme author defines various widget areas, that allows adjustments in more areas than just the sidebar. I do this for example in the theme Greyfoto, where the footer area is also equipped with widgets.<br />
<span id="more-1871"></span><br />
In the following example code we define a widget area, called <em>My Lorem Ipsum Sidebar</em>, which contains &#8222;detailed&#8220; information.</p>
<pre lang="php">
if ( function_exists(&#039;register_sidebar&#039;) ) {
    register_sidebar(array(
        &#039;name&#039; =&gt; &#039;My Lorem Ipsum Sidebar&#039;,
        &#039;description&#039; =&gt; __(&#039;Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.&#039;, &#039;your_textdomain&#039;),
        &#039;before_widget&#039; =&gt; &#039;&lt;li id=&quot;%1$s&quot; class=&quot;widget %2$s&quot;&gt;&#039;,
        &#039;after_widget&#039; =&gt; &#039;&lt;/li&gt;&#039;,
        &#039;before_title&#039; =&gt; &#039;&lt;h2 class=&quot;widgettitle&quot;&gt;&#039;,
        &#039;after_title&#039; =&gt; &#039;&lt;/h2&gt;&#039;,
    ));
}
</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/wp-widgets.png" alt="wp-widgets" title="wp-widgets" width="450" height="335" class="aligncenter size-full wp-image-1872" /></p>
<p>A more comprehensive example with two widget areas, one area for the sidebar and an area for the footer.</p>
<pre lang="php">
if ( function_exists(&#039;register_sidebar&#039;) ) {
    register_sidebar(array(
        &#039;id&#039; =&gt; &#039;sidebar&#039;,
        &#039;name&#039; =&gt; &#039;My Lorem Ipsum Sidebar&#039;,
        &#039;description&#039; =&gt; __(&#039;Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.&#039;, &#039;your_textdomain&#039;),
        &#039;before_widget&#039; =&gt; &#039;&lt;li id=&quot;%1$s&quot; class=&quot;widget %2$s&quot;&gt;&#039;,
        &#039;after_widget&#039; =&gt; &#039;&lt;/li&gt;&#039;,
        &#039;before_title&#039; =&gt; &#039;&lt;h2 class=&quot;widgettitle&quot;&gt;&#039;,
        &#039;after_title&#039; =&gt; &#039;&lt;/h2&gt;&#039;,
    ));

    register_sidebar(array(
        &#039;id&#039; =&gt; &#039;footer&#039;,
        &#039;name&#039; =&gt; &#039;My Lorem Ipsum Footer&#039;,
        &#039;description&#039; =&gt; __(&#039;Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.&#039;, &#039;your_textdomain&#039;),
        &#039;before_widget&#039; =&gt; &#039;&lt;li id=&quot;%1$s&quot; class=&quot;widget %2$s&quot;&gt;&#039;,
        &#039;after_widget&#039; =&gt; &#039;&lt;/li&gt;&#039;,
        &#039;before_title&#039; =&gt; &#039;&lt;h2 class=&quot;widgettitle&quot;&gt;&#039;,
        &#039;after_title&#039; =&gt; &#039;&lt;/h2&gt;&#039;,
    ));
}
</pre>
<p>This may be used as follows in the templates, it's being used in the <code>footer.php</code> of the widget area <em>My Lorem Ipsum Footer</em>.</p>
<pre lang="html4strict">
&lt;div id=&quot;footer&quot;&gt;
    &lt;ul&gt;
        &lt;?php dynamic_sidebar(&#039;footer&#039;); ?&gt;
    &lt;/ul&gt;
&lt;/div&gt;
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1871/wordpress-widget-areas-with-description/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Ultimative Guide For the_post_thumbnail In WordPress 2.9</title>
		<link>http://wpengineer.com/1930/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/</link>
		<comments>http://wpengineer.com/1930/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 06:50:48 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[template tag]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1930</guid>
		<description><![CDATA[WordPress 2.9 RC1 is released and the new post thumbnail function will not change until the final version hopefully. I was chatting a little bit with Sergej Müller last night and we were trying some things out. We found out the following things: Edit: Some little changes, see Matt's comment. You can provide 4 picture [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-18.jpg" alt="WordPress-Christmas-18" title="WordPress-Christmas-18" width="600" height="400" class="aligncenter size-full wp-image-1896" />WordPress 2.9 RC1 is released and the new post thumbnail function will not change until the final version hopefully.<br />
I was chatting a little bit with <a title="wpSEO WordPress SEO Plugin" href="http://wpseo.org">Sergej Müller</a> last night and we were trying some things out. We found out the following things:<br />
<span id="more-1930"></span><br />
<strong>Edit:</strong> Some little changes, see <a href="http://wpengineer.com/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/#comment-3053">Matt's comment</a>.</p>
<p>You can provide 4 picture formats to the function (change the width and height values to your need):</p>
<pre lang="php">
// the thumbnail
the_post_thumbnail(array(100,100)); 

// medium resolution
the_post_thumbnail(array(300,200));

// large resolution
the_post_thumbnail(array(600, 400));

// original
the_post_thumbnail();
</pre>
<p>You can set how the images should align. It is also possible to assign an own class:</p>
<pre lang="php">
//  left align
the_post_thumbnail(array(100,100), array(&#039;class&#039; =&gt; &#039;alignleft&#039;));

//  right align
the_post_thumbnail(array(100,100), array(&#039;class&#039; =&gt; &#039;alignright&#039;));

//  center
the_post_thumbnail(array(100,100), array(&#039;class&#039; =&gt; &#039;aligncenter&#039;));

// align right and the class  &#039;my_own_class&#039;
the_post_thumbnail(array(100,100), array(&#039;class&#039; =&gt; &#039;alignright my_own_class&#039;));
</pre>
<p>The 3rd possibility is the control of the images size with an array of height and width:<br />
For this purpose we suppose that the settings for thumbnail is 150x150, for medium 300x200 and for large 600x400.</p>
<pre lang="php">
// thumbnail scaled to 60x60 pixel
the_post_thumbnail(array(60,60), array(&#039;class&#039; =&gt; &#039;alignleft&#039;)); 

// original thumbnail
the_post_thumbnail(array(150,150), array(&#039;class&#039; =&gt; &#039;alignleft&#039;));

// medium resolution scaled to 200x133 pixel
the_post_thumbnail(array(200,200), array(&#039;class&#039; =&gt; &#039;alignleft&#039;));

// large resolution scaled to 400x266 Pixel
the_post_thumbnail(array(400,345), array(&#039;class&#039; =&gt; &#039;alignleft&#039;));
</pre>
<p>We see that the image proportions are always maintained, even if one specifies crooked values.</p>
<p>For the Theme Designers is this not necessarily easier, because no one knows what the user will put in his settings o his library. One way to approach this problem, to query the options for the various sizes:</p>
<pre lang="php">
// width of the thumbnails
get_option(&#039;thumbnail_size_w&#039;);

//  height of the thumbnails
get_option(&#039;thumbnail_size_h&#039;);

//  height of the medium resolution
get_option(&#039;medium_size_h&#039;);

//  width of the large resolution
get_option(&#039;large_size_w&#039;);

//  1 = Crop thumbnail to exact dimensions, 0 = Crop off
get_option(&#039;thumbnail_crop&#039;)
</pre>
<p>You can change these values in your theme.</p>
<pre lang="php">
$w = get_option(&#039;thumbnail_size_w&#039;) / 2;
$h = get_option(&#039;thumbnail_size_h&#039;) /2;

the_post_thumbnail(array($w, $h), array(&#039;class&#039; =&gt; &#039;alignleft&#039;));
</pre>
<p>Here another example: If the size of a thumbnail is bigger than 100x100 and crop is activated, then the thumbnail should be resized to 100x100, otherwise use the original thumbnail.</p>
<pre lang="php">
if(get_option(&#039;thumbnail_size_w&#039;) &gt; 100 &amp;&amp; get_option(&#039;thumbnail_crop&#039;) == 1) {
    the_post_thumbnail(array(100,100));
}else{
    the_post_thumbnail(&#039;thumbnail&#039;);
}
</pre>
<p>Have fun with post thumbnails! But be aware, that each post thumbnail requires 2 data base queries. On a page with 10 posts that would be 20 more queries.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1930/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/feed/</wfw:commentRss>
		<slash:comments>107</slash:comments>
		</item>
		<item>
		<title>Extend the User Contact Info in WordPress 2.9</title>
		<link>http://wpengineer.com/1877/extend-user-contactinfo-wordpress-29/</link>
		<comments>http://wpengineer.com/1877/extend-user-contactinfo-wordpress-29/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 07:19:25 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[template tag]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1877</guid>
		<description><![CDATA[Joost de Valk wrote about a month ago a really great article about his idea, to expand the user contact fields (thanks Joost!). In version 2.9 you are able to use this possibility. Here a little example, how you can use this functionality. First you write your own function in your functions.php of your theme. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-16.jpg" alt="WordPress-Christmas-16" title="WordPress-Christmas-16" width="600" height="400" class="aligncenter size-full wp-image-1894" /><br />
<a title="Tweaking Websites" href="http://yoast.com">Joost de Valk</a> wrote about a month ago a <a title="User Contact Fields in WordPress 2.9" href="http://yoast.com/user-contact-fields-wp29/">really great article</a> about his idea, to expand the user contact fields (thanks Joost!). In version 2.9 you are able to use this possibility. Here a little example, how you can use this functionality.<br />
<span id="more-1877"></span><br />
First you write your own function in your functions.php of your theme.</p>
<pre lang="php">
&lt;?php
function my_new_contactmethods( $contactmethods ) {
  // Add Twitter
  $contactmethods&#091;&#039;twitter&#039;&#093; = &#039;Twitter&#039;;
  //add Facebook
  $contactmethods&#091;&#039;facebook&#039;&#093; = &#039;Facebook&#039;;

  return $contactmethods;
}
add_filter(&#039;user_contactmethods&#039;,&#039;my_new_contactmethods&#039;,10,1);
?&gt;
</pre>
<p>This function does nothing more than expand the array $contactmethods with the fields twitter and facebook. The value behind the fields is used as a label for the input fields. You can also remove existing fields, here the field of YAHOO IM:</p>
<pre lang="php">
  // Remove Yahoo IM
  unset($contactmethods&#091;&#039;yim&#039;&#093;);
</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/wordpress-contact-info.png" alt="WordPress contact info edit screen" title="WordPress contact info edit screen" width="557" height="289" class="aligncenter size-full wp-image-1878" /></p>
<p>This fields can be displayed on the author page.</p>
<pre lang="php">
&lt;?php
$current_author = get_userdata(get_query_var(&#039;author&#039;));
?&gt;
&lt;p&gt;&lt;a href=&quot;&lt;?php echo esc_url($current_author-&gt;twitter);?&gt;&quot; title=&quot;Twitter&quot;&gt; Follow me on Twitter&lt;/a&gt;&lt;/p&gt;
</pre>
<p>Alternatively you can also use the template tag the_author_meta.</p>
<pre lang="php">
the_author_meta(&#039;facebook&#039;, $current_author-&gt;ID)
</pre>
<p>That's all behind the 16ht door of our Advent Calendar. <img src='http://wpengineer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Have fun expanding your contact fields.</p>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1877/extend-user-contactinfo-wordpress-29/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Manage Multiple Excerpt Lengths</title>
		<link>http://wpengineer.com/1909/manage-multiple-excerpt-lengths/</link>
		<comments>http://wpengineer.com/1909/manage-multiple-excerpt-lengths/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 06:58:31 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[template tag]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1909</guid>
		<description><![CDATA[Behind our 10th door of our Advent Calendar, we have a tip how to use multiple excerpt lengths. WordPress 2.9 allows you via filter to adjust excerpt more string and the length of the excerpt. But if you need several excerpt lengths for different templates, then what? Suppose we even need an excerpt of 30 [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-10.jpg" alt="WordPress-Christmas-10" title="WordPress-Christmas-10" width="600" height="400" class="aligncenter size-full wp-image-1888" />Behind our 10th door of our Advent Calendar, we have a tip how to use multiple excerpt lengths. WordPress 2.9 allows you via filter to adjust <a title="New excerpt filters in WordPress 2.9" href="http://wpengineer.com/wordpress-2-9-new-excerpt-filters/">excerpt more string</a> and the <a title="New excerpt filters in WordPress 2.9" href="http://wpengineer.com/wordpress-2-9-new-excerpt-filters/">length of the excerpt</a>. But if you need several excerpt lengths for different templates, then what?<br />
<span id="more-1909"></span><br />
Suppose we even need an excerpt of 30 words, and once with 45 words and "..." as more string.<br />
First, we write the filter functions with the required values.</p>
<pre lang="php">
function wpe_excerptlength_teaser($length) {
    return 45;
}
function wpe_excerptlength_index($length) {
    return 30;
}
function wpe_excerptmore($more) {
    return &#039;...&#039;;
}
</pre>
<p>Now the new excerpt function.</p>
<pre lang="php">
function wpe_excerpt($length_callback=&#039;&#039;, $more_callback=&#039;&#039;) {
    global $post;
    if(function_exists($length_callback)){
        add_filter(&#039;excerpt_length&#039;, $length_callback);
    }
    if(function_exists($more_callback)){
        add_filter(&#039;excerpt_more&#039;, $more_callback);
    }
    $output = get_the_excerpt();
    $output = apply_filters(&#039;wptexturize&#039;, $output);
    $output = apply_filters(&#039;convert_chars&#039;, $output);
    $output = &#039;&lt;p&gt;&#039;.$output.&#039;&lt;/p&gt;&#039;;
    echo $output;
}
</pre>
<p>This function will be given the two filter functions. It will examine whether those features are available and if so, we applied the filter. Isn't there a length function, then WordPress applies the default value of 55 words. Thereafter, the excerpt will be taken. Then additional filters are applied (see default_filters.php). I haven't used the filter convert_smilies, it doesn't work with automatic excerpts anyways and I personally do not like wpautop because it comes with unpredictable results, especially in lists or code. That's why I wrapp the outputs with a clause.</p>
<p>Now we need the function in the template.</p>
<pre lang="php">
&lt;?php wpe_excerpt(&#039;wpe_excerptlength_index&#039;, &#039;wpe_excerptmore&#039;); ?&gt;
// the other one
&lt;?php wpe_excerpt(&#039;wpe_excerptlength_teaser&#039;, &#039;wpe_excerptmore&#039;); ?&gt;
</pre>
<p>Now, it makes no sense to write for any value of 1-55, a filter function <img src='http://wpengineer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> , but for 2-3 different values in different views, the solution is useful.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1909/manage-multiple-excerpt-lengths/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Configure WordPress Trash</title>
		<link>http://wpengineer.com/1874/configure-wordpress-trash/</link>
		<comments>http://wpengineer.com/1874/configure-wordpress-trash/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 07:38:54 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1874</guid>
		<description><![CDATA[Check out our 7th door of our Advent Calendar. WordPress Trash will have it's premiere in version 2.9. Now you can move every content, comment, post, pages, media and link to trash. It's quite the same function as you know from other online applications or operating systems. If you like to configure a special date [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-07.jpg" alt="WordPress-Christmas-07" title="WordPress-Christmas-07" width="600" height="400" class="aligncenter size-full wp-image-1885" />Check out our 7th door of our Advent Calendar.</p>
<p><a href="http://wpengineer.com/wordpress-trash-is-coming/">WordPress Trash</a> will have it's premiere in version 2.9. Now you can move every content, comment, post, pages, media and link to trash. It's quite the same function as you know from other online applications or operating systems.<br />
<span id="more-1874"></span><br />
If you like to configure a special date of how long files should be kept in your trash, you can configure it in your wp-config.php.<br />
<code>define( 'EMPTY_TRASH_DAYS', 10 );</code></p>
<p>The default settings deletes your content after 30 days. If you don't want to use trash at all, just use the value <code>0</code>.</p>
<p><code>define('EMPTY_TRASH_DAYS', 0);</code></p>
<p>Now there is no trash in your admin area available, and also no links to move files to your trash.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1874/configure-wordpress-trash/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>2nd Door Of Our Advent Calendar &#8211; Support in WordPress for rel=&#8221;canonical&#8221;</title>
		<link>http://wpengineer.com/1866/support-in-wordpress-for-relcanonical/</link>
		<comments>http://wpengineer.com/1866/support-in-wordpress-for-relcanonical/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 07:05:32 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1866</guid>
		<description><![CDATA[WordPress 2.9 will support the attribute rel and his value canonical, you can also read about it on an older post how to integrate the values and what's about it. Therefore you don't have to paste the HTML explicitly in your theme. In previous versions of WordPress 2.9, the intergration is easy to do: &#60;?php [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-02.jpg" alt="WordPress-Christmas-02" title="WordPress-Christmas-02" width="600" height="400" class="aligncenter size-full wp-image-1880" /><br />
WordPress 2.9 will support the attribute <code>rel</code> and his value <code>canonical</code>, you can also read about it on <a href="http://wpengineer.com/relcanonical-url-for-wordpress-theme/">an older post</a> how to integrate the values and what's about it. Therefore you don't have to paste the HTML explicitly in your theme.</p>
<p>In previous versions of WordPress 2.9, the intergration is easy to do:</p>
<pre lang="php">
&lt;?php if ( is_singular() ) echo &#039;&lt;link rel=&quot;canonical&quot; href=&quot;&#039; . get_permalink() . &#039;&quot; /&gt;&#039;; ?&gt;
</pre>
<p>Putting it in the header.php of the theme is the easiest way to have the link-tag in the <code>head</code> of your frontend.</p>
<p>Since WordPress 2.9 it won't be necessary because WordPress set with the help of the default filter, see <code>wp-includes/default-filters.php</code>, the <code>link</code>-tag to the hook <code>wp_head</code>.</p>
<pre lang="php">
add_action( &#039;wp_head&#039;, &#039;rel_canonical&#039; );
</pre>
<p>Thereby it calls the function <code>rel_canonical()</code>, which simply writes the HTML and passes the link of the article. Alternatively you can disable the filter and you can use it yourself.</p>
<pre lang="php">
remove_action( &#039;wp_head&#039;, &#039;rel_canonical&#039; ); // to delete in head
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1866/support-in-wordpress-for-relcanonical/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress Database Repair Script In 2.9</title>
		<link>http://wpengineer.com/1836/wordpress-database-repair-script-in-2-9/</link>
		<comments>http://wpengineer.com/1836/wordpress-database-repair-script-in-2-9/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 17:21:35 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress News]]></category>
		<category><![CDATA[Constants]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1836</guid>
		<description><![CDATA[A little tip for all users of the existing beta of WordPress 2.9 and for all who wish to update soon to the new version. With version 2.9 WordPress conducts its own routine to optimize the database. Previously it was done by either Plugins or via SQL access. From the next version this function is [...]]]></description>
			<content:encoded><![CDATA[<p>A little tip for all users of the existing beta of WordPress 2.9 and for all who wish to update soon to the new version. With version 2.9 WordPress conducts its own routine to optimize the database. Previously it was done by either Plugins or via SQL access. From the next version this function is implemented in the core ...<br />
<span id="more-1836"></span><br />
<a href="http://wpengineer.com/wp-content/uploads/wprdb11.png"><img src="http://wpengineer.com/wp-content/uploads/wprdb11-300x78.png" alt="wprdb1" title="wprdb1" width="300" height="78" class="aligncenter size-medium wp-image-1838" /></a></p>
<p>... which you can activate with the help of a constant; stored in <code>wp-config.php</code>, you have access to the script.</p>
<pre lang="php">
define(&#039;WP_ALLOW_REPAIR&#039;, true);
</pre>
<p>Call the script from the outside at the following address ...<br />
<code>http://example.com/wp-admin/maint/repair.php</code></p>
<p>... where you either repair the database or run the optimization. Technically, there is no magic behind this work, but the familiar SQL statements <a href="http://dev.mysql.com/doc/refman/5.1/en/analyze-table.html"><code>ANALYZE TABLE</code></a>, <a href="http://dev.mysql.com/doc/refman/5.1/en/repair-table.html"><code>REPAIR TABLE</code></a> and <a href="http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html"><code>OPTIMIZE TABLE</code></a>.</p>
<p><a href="http://wpengineer.com/wp-content/uploads/wprdb.png"><img src="http://wpengineer.com/wp-content/uploads/wprdb-300x127.png" alt="wprdb" title="wprdb" width="300" height="127" class="aligncenter size-medium wp-image-1841" /></a></p>
<p>I guess that will start a debate, why with the constant and why from the outside, etc. - leave your comment here. Alternatively, anyone can contribute to WordPress and discuss directly with the developers or enter changes directly to the code.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1836/wordpress-database-repair-script-in-2-9/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WordPress 2.9 add_theme_support and has_post_image</title>
		<link>http://wpengineer.com/1779/wordpress-2-9-add_theme_support-and-has_post_image/</link>
		<comments>http://wpengineer.com/1779/wordpress-2-9-add_theme_support-and-has_post_image/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 21:16:55 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress News]]></category>
		<category><![CDATA[post_thumbnail]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1779</guid>
		<description><![CDATA[The new the_post_image functionality in WordPress version 2.9 has been enhanced. New is the wp-settings.php line // Load in support for template functions which the theme supports require_if_theme_supports( &#039;post-thumbnails&#039;, ABSPATH . WPINC . &#039;/post-image-template.php&#039; ); In functions.php it queries whether the theme supports post-thumbnail function: if ( function_exists( &#039;add_theme_support&#039; ) ) add_theme_support( &#039;post-thumbnails&#039; ); If [...]]]></description>
			<content:encoded><![CDATA[<p>The new <a title="Article New feature in WordPress 2.9 – the_post_image()" href="http://wpengineer.com/new-feature-in-wordpress-2-9-the_post_image/"><strong> the_post_image</strong ></a> functionality in WordPress version 2.9 has been enhanced.<br />
New is the wp-settings.php line<br />
<span id="more-1779"></span></p>
<pre lang="php">
// Load in support for template functions which the theme supports
require_if_theme_supports( &#039;post-thumbnails&#039;, ABSPATH . WPINC . &#039;/post-image-template.php&#039; );
</pre>
<p>In functions.php it queries whether the theme supports post-thumbnail function:</p>
<pre lang="php">
if ( function_exists( &#039;add_theme_support&#039; ) )
	add_theme_support( &#039;post-thumbnails&#039; );
</pre>
<p>If you look at the file wp-includes/post-image-template.php, there are 4 new features:</p>
<ul>
<li><strong>has_post_image()</strong></li>
<li><strong>get_post_image_id()</strong></li>
<li><strong>the_post_image()</strong></li>
<li><strong>get_the_post_image()</strong></li>
</ul>
<p>The theme itself can check within the loop, if the post has a Post-Thumbnail, and if so, then it can be output:</p>
<pre lang="php">
&lt;?php if ( has_post_image() ) : ?&gt;
	&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_post_image( array( 75, 75 ), array( &#039;class&#039; =&gt; &#039;alignleft&#039; ) ); ?&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;
</pre>
<p>Those interested in more features and information should check the file in WordPress 2.9: <code>wp-includes/post-image-template.php</code><br />
Especially the function: <code>get_the_post_image</code><br />
It allows to adjust the output by using hooks.<br />
In <code>get_the_post_image</code> the function <code>wp_get_attachment_image</code> get also used, what has been explained in detail in <a href="http://wpengineer.com/easier-better-solutions-to-get-pictures-on-your-posts/">this post just a few days ago</a>.</p>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1779/wordpress-2-9-add_theme_support-and-has_post_image/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Batch Plugin-Update in WordPress 2.9</title>
		<link>http://wpengineer.com/1766/batch-plugin-update-in-wordpress-2-9/</link>
		<comments>http://wpengineer.com/1766/batch-plugin-update-in-wordpress-2-9/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 10:58:37 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress News]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1766</guid>
		<description><![CDATA[In the past we have already informed you a little bit about the new features of the upcoming 2.9 version of WordPress - the development does not stop and the next version has many minor changes. Improvements in security, administration. WordPress 2.9 will have the possibility to update all your Plugins, which have an update [...]]]></description>
			<content:encoded><![CDATA[<p>In the past we have already informed you a little bit about the new features of the upcoming 2.9 version of WordPress - the development does not stop and the next version has many minor changes. Improvements in security, administration.</p>
<p>WordPress 2.9 will have the possibility to update all your Plugins, which have an update available, in one step.<br />
That makes maintenance work with customer's and on your own blog more simple and faster. As a little insight, here is a screenshot of the current beta.</p>
<p><a href="http://wpengineer.com/wp-content/uploads/plugin-update-29.png"><img src="http://wpengineer.com/wp-content/uploads/plugin-update-29-300x291.png" alt="plugin-update-29" title="plugin-update-29" width="300" height="291" class="aligncenter size-medium wp-image-1767" /></a><br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1766/batch-plugin-update-in-wordpress-2-9/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

