<?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>Indiana University: IT Training Tips Blog &#187; WordPress</title>
	<atom:link href="http://ittrainingtips.iu.edu/category/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://ittrainingtips.iu.edu</link>
	<description>Tips and tricks to help you make the most of technology</description>
	<lastBuildDate>Thu, 16 May 2013 16:17:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress: Including Category RSS Feed Links Using the Default Category Widget</title>
		<link>http://ittrainingtips.iu.edu/content-management/wordpress-including-category-rss-feed-links-using-the-default-category-widget/10/2010</link>
		<comments>http://ittrainingtips.iu.edu/content-management/wordpress-including-category-rss-feed-links-using-the-default-category-widget/10/2010#comments</comments>
		<pubDate>Mon, 11 Oct 2010 12:00:41 +0000</pubDate>
		<dc:creator>Tom Mason</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[WCMS]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://ittrainingtips.iu.edu/?p=1533</guid>
		<description><![CDATA[One of the benefits of administering this blog is that it allows me to find gaps in the WordPress documentation already published to the web and/or find easier ways to do things than what has already been explained. Today, I&#8217;m looking into how to create the category RSS feeds that you can see in our [...]]]></description>
				<content:encoded><![CDATA[<p>One of the benefits of  administering this blog is that it allows me to find gaps in the WordPress documentation already published to the web and/or find easier ways to do things than what has already been explained.</p>
<p>Today, I&#8217;m looking into how to create the category RSS feeds that you can see in our sidebar. This article will discuss how to create the following by editing the default WordPress category sidebar widget:</p>
<table border="0">
<tbody>
<tr>
<td><strong>RSS Feed text links:</strong></p>
<p><img class="alignnone size-full wp-image-1534" title="rss_text_categories" src="http://ittrainingtips.iu.edu/wp-content/uploads/2010/10/rss_text_categories.jpg" alt="Category Text RSS Links" /></p>
</td>
<td><strong>RSS Feed icon links:</strong></p>
<p><img class="alignnone size-full wp-image-1535" title="rss_icon_categories" src="http://ittrainingtips.iu.edu/wp-content/uploads/2010/10/rss_icon_categories.jpg" alt="Category RSS Image Links" /></p>
</td>
</tr>
</tbody>
</table>
<p style="padding-left: 30px;"><em>NOTE: This article is intended for individuals who are working with WordPress at an administrative level. A familiarity with PHP is required.</em></p>
<p><strong>WordPress Version: 2.8.0 and up</strong></p>
<p>
  <span id="more-1533"></span>
</p>
<h3>Understanding How Category Lists Are Generated</h3>
<p>Before we dive into the specifics of how to edit the Category widget, let&#8217;s explore how Category links are made.</p>
<p>In the most recent version of WordPress (3.0.1 at the time of this writing), the function that generates categories is called <a href="http://codex.wordpress.org/Template_Tags/wp_list_categories" target="_blank"><code>wp_list_categories()</code></a> (link opens in new window). I will spare you the entire explanation of how the function works (follow the link to go to the WordPress Codex), but we will need a general working knowledge of how we will send it input.</p>
<p>The typical usage is:</p>
<p><code>&lt;?php wp_list_categories($args); ?&gt; </code></p>
<p>Where <code>$args</code> is an array that passes display settings to the function.</p>
<h4>Dynamic vs. Static Sidebar: Which One Am I Using?</h4>
<p>This article focuses on the dynamic sidebar. The easiest way to tell if you are using a dynamic or static sidebar is whether or not you are using widgets in your theme. If you use widgets, you are using a dynamic sidebar. If you aren&#8217;t using widgets, you are using a static sidebar. If you are using a static sidebar, you will probably still get some helpful information out of this post, but it&#8217;s truly geared toward the dynamic sidebar.</p>
<h3>Creating Category RSS Feed Text Links</h3>
<p>Let&#8217;s start with the easier of the two methods, text-based RSS links.</p>
<ol>
<li>To begin, you need to find your <strong>wp-includes/default-widgets.php</strong> file. </li>
<li>Save the current file as <strong>wp-includes/default-widgets-OLD.php</strong>.</li>
</ol>
<p>Now that we&#8217;ve backed up our work, we can begin looking for the code we need. In the file, you should find an area of text around line 414 that looks like:</p>
<pre>
/**
 * Categories widget class
 *
 * @since 2.8.0
 */
class WP_Widget_Categories extends WP_Widget {

	function WP_Widget_Categories() {
		$widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) );
		$this->WP_Widget('categories', __('Categories'), $widget_ops);
	}

	function widget( $args, $instance ) {
		extract( $args );

		$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base);
		$c = $instance['count'] ? '1' : '0';
		$h = $instance['hierarchical'] ? '1' : '0';
		$d = $instance['dropdown'] ? '1' : '0';

		echo $before_widget;
		if ( $title )
			echo $before_title . $title . $after_title;

		$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);

		if ( $d ) {
			$cat_args['show_option_none'] = __('Select Category');
			wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args));
?>
</pre>
<p>There are essentially two locations we are interested in in this code chunk. The first is where we will declare our feed link&#8217;s name:</p>
<p><code> $c = $instance['count'] ? '1' : '0';<br />
$h = $instance['hierarchical'] ? '1' : '0';<br />
$d = $instance['dropdown'] ? '1' : '0';
</p>
<p></code></p>
<p>The second is where we modify the <code>$cat_args</code> array:</p>
<p><code>$cat_args = array('orderby' =&gt; 'name', 'show_count' =&gt; $c, 'hierarchical' =&gt; $h);</code></p>
<p>We will add a $f variable and set it&#8217;s value to &#8216;rss&#8217;. We will then add the variable in the $cat_args array to make the links appear.</p>
<ol>
<li>To create the <code>$f</code> variable, in the code editor, under the line that reads <code>$d = $instance['dropdown'] ? '1' : '0';</code> type,<br />
    <strong><code>$f = 'rss';</code> </strong></li>
<li>To modify the <code>$cat_args</code> array, immediately after the <code>$h</code>, type:<br />
    <strong><code>, 'feed' =&gt; $f</code></strong></p>
<p>    The line should now read: <strong>$cat_args = array(&#8216;orderby&#8217; => &#8216;name&#8217;, &#8216;show_count&#8217; => $c, &#8216;hierarchical&#8217; => $h, &#8216;feed&#8217; =&gt; $f);</strong></p>
<p>    <a href="http://ittrainingtips.iu.edu/media/wordpress/categoryrss/categoryRSSText.html" target="_blank">Full code listing for the WP_Widget_Categories class.</a> (opens in new window)</li>
<li>Save your file and upload it back to your <strong>wp-includes</strong> folder.</li>
<li>Refresh your blog front page.</li>
</ol>
<p>You should see something similar to:<br />
  <img class="alignnone size-full wp-image-1534" title="rss_text_categories" src="http://ittrainingtips.iu.edu/wp-content/uploads/2010/10/rss_text_categories.jpg" alt="Category Text RSS Links" width="205" height="358" /></p>
<h3>Creating Category RSS Icon Links</h3>
<p>The process for creating RSS links with an icon is very similar to the above process. Instead of settign the <code>$f</code> variable to <code>'rss'</code>, we will set it to the location of the image file and instead of adding <code>'feed' =&gt; $f</code> to the <code>$cat_args</code> array, we will add <code>'feed_image' =&gt; $f</code>. </p>
<p>To complete this section, you will need a small RSS icon. <a href="http://ittrainingtips.iu.edu/wp-content/themes/ITTE/images/feedico_x-sm.gif">Right click here and choose &#8216;Save Target As&#8230;&#8217;</a> to use the one that we use. You will also have to upload the image to a folder you can link to from your WordPress installation, we stored ours in our wp-content/themes/current_theme/images folder.</p>
<p>Let&#8217;s get started.</p>
<ol>
<li>Find the same code snippets listed above, namely:<br />
    <code>$c = $instance['count'] ? '1' : '0';<br />
    $h = $instance['hierarchical'] ? '1' : '0';<br />
    $d = $instance['dropdown'] ? '1' : '0';
    </p>
<p>    </code></li>
<li>To create the feed variable, after <code>$d</code>, type:<br />
    <strong>$f = &#8216;path_to_your.image&#8217;</strong></li>
<li>To modify the $cat_args variable, immediately after the $h, type:<br />
    <strong>, &#8216;feed_image&#8217; =&gt; $f</strong> </p>
<p>    The line should now read: <strong>$cat_args = array(&#8216;orderby&#8217; =&gt; &#8216;name&#8217;, &#8216;show_count&#8217; =&gt; $c, &#8216;hierarchical&#8217; =&gt; $h, &#8216;feed_image&#8217; =&gt; $f);</strong> </p>
<p>    <a href="http://ittrainingtips.iu.edu/media/wordpress/categoryrss/categoryRSSIcon.html" target="_blank">Full code listing for the WP_Widget_Categories class.</a> (opens in new window)</li>
<li>Save your file and upload it back to your wp-includes folder.</li>
<li>Refresh your blog front page.</li>
</ol>
<p>You should see something similar to: <br />
<img class="alignnone size-full wp-image-1535" title="rss_icon_categories" src="http://ittrainingtips.iu.edu/wp-content/uploads/2010/10/rss_icon_categories.jpg" alt="Category RSS Image Links" /></p>
<h3>Where To Go From Here</h3>
<p>Now that you have modified your <strong>default-widgets.php</strong> file, you will have to preserve it before upgrading your WordPress installation. I recommend that you keep a copy of the modified file stored somewhere safe. For example, you could save your <strong>default-widgets.php</strong> file as <strong>default-widgets-NEW.php</strong> and move it to your desktop or any other location.</p>
]]></content:encoded>
			<wfw:commentRss>http://ittrainingtips.iu.edu/content-management/wordpress-including-category-rss-feed-links-using-the-default-category-widget/10/2010/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>
