<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.smor.tv/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"> <channel><title>SMOR.tv : Sam Morris » WordPress Tutorials</title> <link>http://www.smor.tv</link> <description /> <lastBuildDate>Mon, 11 Oct 2010 03:58:21 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=</generator> <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.smor.tv/smortv-tuts-wp" /><feedburner:info uri="smortv-tuts-wp" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>smortv-tuts-wp</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item><title>WordPress Title Trimming Tutorial</title><link>http://feeds.smor.tv/~r/smortv-tuts-wp/~3/Q6_IWb46ZiQ/</link> <comments>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-title-trimming-tutorial/#comments</comments> <pubDate>Sat, 06 Feb 2010 19:43:21 +0000</pubDate> <dc:creator>Sam Morris</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <guid isPermaLink="false">http://www.smor.tv/?p=1056</guid> <description><![CDATA[<p>This tutorial will show you how to trim title lengths for long post or page titles, which can be helpful for keeping the layout of your website consistent. My example uses the WordPress get_the_title template tag, but this could easily...Read More</p>]]></description> <content:encoded><![CDATA[<p>This tutorial will show you how to trim title lengths for long post or page titles, which can be helpful for keeping the layout of your website consistent. My example uses the WordPress get_the_title template tag, but this could easily be modified for other uses.</p><p>Start off by opening your functions.php within your WordPress theme folder:<br
/> (wp-content\themes\themename\functions.php)<br
/> If you don&#8217;t have a one, you can create a new file and call it functions.php.</p><p>Next copy the following code into your functions.php, save and then upload the file. Watch out for the PHP tags when copying the code, you&#8217;ll most likely only need them if you&#8217;re starting a blank document.</p><blockquote><p> // Title Trimmer (Version 3)<br
/> // Sam Morris &#8211; 12.28.2009<br
/> // www.smor.tv</p><p>function title_trimmer($title , $maxLength)<br
/> {<br
/> $titleLength = strlen($title); // get the amount of characters in the title</p><p>// start conditional<br
/> if ($titleLength &amp;gt; $maxLength) // if the title length is over the max length, then we start the trimming process.<br
/> {<br
/> $trimmedTitle = substr_replace($title,&#8221;",$maxLength);<br
/> echo $trimmedTitle;<br
/> //echo $trimmedTitle . &#8220;&#8230;&#8221;; //use this instead of the line above if you prefer having a &#8230; after your trimmed titles.<br
/> }<br
/> else<br
/> {<br
/> echo $title;<br
/> }<br
/> }</p></blockquote><p>WordPress has many built in functions, but the functions.php is where you can place your own custom functions. When your theme&#8217;s templates are loaded, so will the functions.php allowing you to use your own functions throughout your theme. Open the template that needs the title trimming, or if you just want to try it out you can open single.php (for posts) or page.php (for pages).</p><p>find the_title, which is what most themes will use by default. When you find it, you can replace it will the following code. The title trimming function has 2 arguments, the first is what should be trimmed and the second argument is the maximum length of characters. In my example I&#8217;m trimming the WordPress title down to a maximum of 10 characters.</p><blockquote><p>title_trimmer(get_the_title() , 10);</p></blockquote><p>Save, upload, and then create a test page or post to see the title trimming in action.</p> <img src="http://feeds.feedburner.com/~r/smortv-tuts-wp/~4/Q6_IWb46ZiQ" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-title-trimming-tutorial/feed/</wfw:commentRss> <slash:comments>10</slash:comments> <feedburner:origLink>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-title-trimming-tutorial/</feedburner:origLink></item> <item><title>WordPress Post Thumbnails Tutorial (Using Custom Fields)</title><link>http://feeds.smor.tv/~r/smortv-tuts-wp/~3/AT9v1G_ZFQU/</link> <comments>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-post-thumbnails-tutorial-using-custom-fields/#comments</comments> <pubDate>Mon, 05 Oct 2009 14:00:57 +0000</pubDate> <dc:creator>Sam Morris</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <guid isPermaLink="false">http://www.smor.tv/?p=774</guid> <description><![CDATA[<p>This tutorial will show you how to add thumbnails for each post using a custom field, then output the thumbnails in your WordPress loop.  Many people prefer browsing using thumbnails, especially for something like a portfolio site where visuals may...Read More</p>]]></description> <content:encoded><![CDATA[<p>This tutorial will show you how to add thumbnails for each post using a custom field, then output the thumbnails in your WordPress loop.  Many people prefer browsing using thumbnails, especially for something like a portfolio site where visuals may be more important to you and your visitors.</p><ol><li>Find page.php in your template directory, which can be found at: /wp-content/themes/yourthemename/page.php.</li><li>Make a copy of the page.php and call it thumb.php.</li><li>Open up thumb.php and add the following code at the very top of the document. This is the code for <a
title="Creating a Custom WordPress Template" href="http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-creating-custom-page-template/">creating a Custom WordPress Template</a>.<br
/> [php]&lt;?php<br
/> /*<br
/> Template Name: Thumbnails<br
/> */<br
/> ?&gt;[/php]</li><li>After uploading your new template into the same folder as page.php (/wp-content/themes/yourthemename/), you should make sure it shows up. Create a new page in WordPress and on the right under Template you should see &#8220;Thumbnails&#8221; in the dropdown. Assuming it&#8217;s showing, create a new page using the template and then go back to thumb.php in your editor.</li><li>Next we&#8217;ll add the thumbnail code, which will need to be placed in the loop. The placement will depend on how your theme is programmed, but a good place to start would be below the_title() or above the_content() (search for these in your template). To explain this code, what we&#8217;re doing is nothing too different from standard HTML. First a div is created for styling and placement, then a link so the thumbnails will link to the article, and finally the thumbnail itself. Notice that the image src is going to be set by a post meta value of thumb. (which will correspond to a custom field of thumb when creating posts). All of this code is then put in a conditional statement, which tells WordPress to only show the thumbnail code if the post has one defined (otherwise we would get empty divs and broken images).<br
/> [php]&lt;?php if (get_post_meta($post-&gt;ID, &quot;thumb&quot;, true) != &quot;&quot;) : ?&gt;<br
/> &lt;div&gt;<br
/> &lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot;&gt;<br
/> &lt;img src=&quot;&lt;?php echo get_post_meta($post-&gt;ID, &quot;thumb&quot;, true); ?&gt;&quot; alt=&quot;&lt;?php the_title(); ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot; /&gt;<br
/> &lt;/a&gt;<br
/> &lt;/div&gt;<br
/> &lt;?php endif;?&gt;<br
/> [/php]</li><li>Save and upload the template again, then create a few test posts and give each a custom field with a name of thumb (which is what we used in the code). Define an image for the value such as http://www.site.com/wp-content/uploads/year/month/image.jpg. Publish your posts and then go to the new page you created using the Thumbnail template. You should see a list of posts, each with the thumbnail you defined.</li><li>Lastly, if you&#8217;re looking for a more automated way of doing this you can use <a
title="WP Post Thumbnails" href="http://wordpress.org/extend/plugins/wp-post-thumbnail/" target="_blank"><strong>WP Post Thumbnail</strong></a>, which is great for client&#8217;s or WordPress users that have limited computer knowledge. It will allow them to upload an image while creating a post, and then resize / crop it (meaning no photoshop or external editor is needed). If you do use this plugin the code will be the same, but the name of your customs fields may be different. The plugin uses a file named wppt.xml to configure the name of the post meta and thumbnail size, etc. This file needs to reside in your theme&#8217;s directory NOT the plugin&#8217;s directory.</li><li>How you style your thumbnail class is up to you, but I highly recommend having a fixed width/height with a hidden overflow (overflow: hidden;). This way when a client decides to use a 10 megapixel 3872 x 2592 image as a thumbnail (which does happen), it will get cut off rather than destroying the layout of the site.</li></ol> <img src="http://feeds.feedburner.com/~r/smortv-tuts-wp/~4/AT9v1G_ZFQU" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-post-thumbnails-tutorial-using-custom-fields/feed/</wfw:commentRss> <slash:comments>3</slash:comments> <feedburner:origLink>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-post-thumbnails-tutorial-using-custom-fields/</feedburner:origLink></item> <item><title>WordPress Featured Post Tutorial (Using Custom Fields)</title><link>http://feeds.smor.tv/~r/smortv-tuts-wp/~3/6FFMgpg13lw/</link> <comments>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-featured-post-tutorial-using-custom-fields/#comments</comments> <pubDate>Sun, 02 Aug 2009 22:31:51 +0000</pubDate> <dc:creator>Sam Morris</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <guid isPermaLink="false">http://www.smor.tv/?p=777</guid> <description><![CDATA[<p>This tutorial will show you how to modify your WordPress loop to only display posts that are marked as featured. We will be using a custom field to set posts as featured and in turn, featured posts are not limited...Read More</p>]]></description> <content:encoded><![CDATA[<p>This tutorial will show you how to modify your WordPress loop to only display posts that are marked as featured. We will be using a custom field to set posts as featured and in turn, featured posts are not limited to one category. Also, because we&#8217;re going to be using custom fields it&#8217;s transparent to the visitors unlike tags or categories which are visible. Alternatively, you could use a &#8220;Featured&#8221; category and <a
title="Looping Through Specific Category" href="http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-looping-category-tutorial/">loop through that specific category</a>.</p><ol
class="spaced"><li>Find index.php in your template directory, which can be found at: /wp-content/themes/yourthemename/index.php.</li><li>Make a copy of the index.php and call it featured.php.</li><li>Open up featured.php and add the following code at the very top of the document. This is the code for <a
title="Creating a Custom WordPress Template" href="http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-creating-custom-page-template/">creating a Custom WordPress Template</a>.<br
/> [php]&lt;?php<br
/> /*<br
/> Template Name: Featured Posts<br
/> */<br
/> ?&gt;[/php]</li><li>Towards the top of the document you should see where the loop is starting, lines 2 and 3 should already be in your document. Copy line 1 and insert it before before the other 2 lines so it looks like the following:<br
/> [php]&lt;?php query_posts(&#8216;meta_key=is_featured&amp;meta_value=yes&#8217;);  ?&gt;<br
/> &lt;?php if (have_posts()) : ?&gt;<br
/> &lt;?php while (have_posts()) : the_post(); ?&gt; [/php]</li><li>What this is doing is telling WordPress to loop through posts that have a custom field of &#8220;is_featured&#8221; set to &#8220;yes&#8221;. Save / Upload featured.php to your template directory and create a new page using the newly created Featured Posts template. If you want this to be your homepage, then go to Settings &gt; Reading, and set your new page as your front page.</li><li>Now to add a featured post add a new post (or edit an existing one), and under the editor add a new custom field for &#8220;is_featured&#8221;. Then give it a value of &#8220;yes&#8221;. Update the post, then go back to your Featured Posts page and you should see the featured post.</li><li>As I mentioned from the start, there&#8217;s many ways of creating featured posts such as categories, tags, etc. Personally I find this method to be best for a few reason&#8230;<ul><li>Using categories means featured posts will probably need 2 categories, one for the real category, and the other just setting it as featured.</li><li>The category method can influence your permalinks, which may make them less descriptive.</li><li>Another method is tag based, but many SEO plugins automatically generated keywords from tags. Having &#8220;featured&#8221; as a keyword on many pages isn&#8217;t going to help with Search Engine Optimization.</li><li>Plug-ins are a good option, but in my opinion somewhat unnecessary for such a simple task.</li><li>The main disadvantage of not using tags or a featured category is users can&#8217;t easily view an archive page with all your featured posts.</li></ul></li></ol> <img src="http://feeds.feedburner.com/~r/smortv-tuts-wp/~4/6FFMgpg13lw" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-featured-post-tutorial-using-custom-fields/feed/</wfw:commentRss> <slash:comments>4</slash:comments> <feedburner:origLink>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-featured-post-tutorial-using-custom-fields/</feedburner:origLink></item> <item><title>WordPress Looping through specific Category Tutorial</title><link>http://feeds.smor.tv/~r/smortv-tuts-wp/~3/EILoqCtqAmI/</link> <comments>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-looping-category-tutorial/#comments</comments> <pubDate>Fri, 19 Jun 2009 07:17:02 +0000</pubDate> <dc:creator>Sam Morris</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <guid isPermaLink="false">http://www.smor.tv/?p=674</guid> <description><![CDATA[<p>This tutorial will show you how to create a WordPress loop for getting posts from a specific category / categories. It&#8217;s similar to an archive page displaying a certain category, but by creating a custom loop there is more flexibility...Read More</p>]]></description> <content:encoded><![CDATA[<p>This tutorial will show you how to create a WordPress loop for getting posts from a specific category / categories. It&#8217;s similar to an archive page displaying a certain category, but by creating a custom loop there is more flexibility and customization options, especially when used in conjunction with custom page templates. A standard WordPress loop generally looks along the lines of this:</p><p>[php]&lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;<br
/> THE CONTENT<br
/> &lt;?php endwhile; else: ?&gt;<br
/> &lt;?php _e(&#8216;No Results&#8217;); ?&gt;<br
/> &lt;?php endif; ?&gt;[/php]</p><p>The issue is in many scenarios you may want to include posts from one or a few categories. The archive feature of WordPress has the capabilities to display posts from a certain category, but it lacks flexibility so instead I prefer to create a custom loop using a page template.</p><p>The new loop is:</p><p>[php]&lt;?php if (have_posts()) : ?&gt;<br
/> &lt;?php<br
/> $thePosts = get_posts(&#8216;numberposts=50&amp;category=1&#8242;);<br
/> foreach($thePosts as $post) :<br
/> setup_postdata($post);<br
/> ?&gt;<br
/> THE CONTENT<br
/> &lt;?php endforeach; ?&gt;<br
/> &lt;?php else : ?&gt;<br
/> No Results<br
/> &lt;?php endif; ?&gt;[/php]</p><p>Assuming you use this loop with a custom page template you now have a way to loop through a certain category as well as the ability to make template customizations without having to modify the built in WordPress archives feature.</p><p>One last improvement&#8230;In my experience if you&#8217;re creating a custom loop like the one above you&#8217;ll probably be having more than one page with specific categories. That being the case, having a hard coded category ID is not efficient. Instead we can use a custom field to add some flexibility:</p><p>[php]&lt;?php<br
/> $category = get_post_meta($post-&gt;ID, &quot;category&quot; true);<br
/> $myPosts = get_posts(&#8216;numberposts=50&amp;category=&#8217; . $category. &#8221;);<br
/> foreach($myPosts as $post) :<br
/> setup_postdata($post);<br
/> ?&gt;<br
/> THE CONTENT<br
/> &lt;?php endforeach; ?&gt;<br
/> &lt;?php else : ?&gt;<br
/> No Results<br
/> &lt;?php endif; ?&gt;[/php]</p><p>When creating a new page you can choose your custom page template and will have the ability to loop through one or multiple categories by adding a custom field for &#8220;category&#8221;, then listing the category ID. In addition, if you wanted to add even more flexibility you could create a second post_meta option for limiting the number of posts that are displayed:</p><p>[php]&lt;?php<br
/> $category = get_post_meta($post-&gt;ID, &quot;category&quot;, true);<br
/> $postLimit = get_post_meta($post-&gt;ID, &quot;posts limit&quot;, true);<br
/> $myPosts = get_posts(&#8216;numberposts=&#8217; . $postLimit. &#8216;&amp;category=&#8217; . $category. &#8221;);<br
/> foreach($myPosts as $post) :<br
/> setup_postdata($post);<br
/> ?&gt;<br
/> THE CONTENT<br
/> &lt;?php endforeach; ?&gt;<br
/> &lt;?php else : ?&gt;<br
/> No Results<br
/> &lt;?php endif; ?&gt;[/php]</p><p>Now you would add two custom fields, one for &#8220;category&#8221; and a second for &#8220;posts limit&#8221;. If you wanted to add more than one category for a page you would list out all the category IDs, seperating them with commas (EX: 1,2,3,4).</p> <img src="http://feeds.feedburner.com/~r/smortv-tuts-wp/~4/EILoqCtqAmI" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-looping-category-tutorial/feed/</wfw:commentRss> <slash:comments>6</slash:comments> <feedburner:origLink>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-looping-category-tutorial/</feedburner:origLink></item> <item><title>WordPress Creating a Custom Page Template</title><link>http://feeds.smor.tv/~r/smortv-tuts-wp/~3/ex18YtF3I6s/</link> <comments>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-creating-custom-page-template/#comments</comments> <pubDate>Tue, 19 May 2009 07:52:05 +0000</pubDate> <dc:creator>Sam Morris</dc:creator> <category><![CDATA[WordPress Tutorials]]></category> <guid isPermaLink="false">http://www.smor.tv/?p=698</guid> <description><![CDATA[<p>Creating a custom page template in WordPress is extremely easy, simply add this code at the top of your page template. Generally the best way to create a custom page template is by creating a copy of your theme&#8217;s page.php...Read More</p>]]></description> <content:encoded><![CDATA[<p>Creating a custom page template in WordPress is extremely easy, simply add this code at the top of your page template. Generally the best way to create a custom page template is by creating a copy of your theme&#8217;s page.php file. Using the existing page template will be a good starting point for most customizations, since most likely many aspects of the custom page will be similar to the original. Also, it&#8217;s much easier to hack away at your code removing sections of a page rather than trying to add them back in.</p><p>The Code:<br
/> [php]<br
/> &lt;?php<br
/> /*<br
/> Template Name: Your Template Name<br
/> */<br
/> ?&gt;<br
/> [/php]<br
/> Most likely right after the page template code will come &lt;?php get_header(); ?&gt; . As a side note, there doesn&#8217;t need to be any correlation between the filename and page template name.</p> <img src="http://feeds.feedburner.com/~r/smortv-tuts-wp/~4/ex18YtF3I6s" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-creating-custom-page-template/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://www.smor.tv/tutorials/wordpress-tutorials/wordpress-creating-custom-page-template/</feedburner:origLink></item> </channel> </rss><!-- Dynamic page generated in 0.507 seconds. --><!-- Cached page generated by WP-Super-Cache on 2011-11-24 17:38:06 --><!-- Compression = gzip -->

