<?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: First element in a list: class="cat-item-first"</title>
<link>http://themeshaper.com/forums/</link>
<description>Help In Shaping WordPress Themes</description>
<language>en</language>
<pubDate>Thu, 09 Feb 2012 03:48:54 +0000</pubDate>

<item>
<title>Chris on "First element in a list: class="cat-item-first""</title>
<link>http://themeshaper.com/forums/topic/first-element-in-a-list-classcat-item-first#post-6807</link>
<pubDate>Tue, 29 Sep 2009 18:55:46 +0000</pubDate>
<dc:creator>Chris</dc:creator>
<guid isPermaLink="false">6807@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Thanks a lot for your help!!
&#60;/p&#62;</description>
</item>
<item>
<title>Baudesign on "First element in a list: class="cat-item-first""</title>
<link>http://themeshaper.com/forums/topic/first-element-in-a-list-classcat-item-first#post-6806</link>
<pubDate>Tue, 29 Sep 2009 18:22:54 +0000</pubDate>
<dc:creator>Baudesign</dc:creator>
<guid isPermaLink="false">6806@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Hum, I just noticed something...&#60;/p&#62;
&#60;p&#62;The widgets that list elements (Archives, Meta, Recent posts, etc.) do not add any class to the &#60;code&#62;&#38;lt;li&#38;gt;&#60;/code&#62; tag, whereas it is the case for categories and pages: cat-item, cat-item-n (where n is a number), page_item (why underscore instead of dash here!?), etc.&#60;br /&#62;
Would it be possible, the same way here, to add a class to the first element of every list? Like so:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;h3 class=&#38;quot;widgettitle&#38;quot;&#38;gt;Title&#38;lt;/h3&#38;gt;
  &#38;lt;ul&#38;gt;
    &#38;lt;li class=&#38;quot;first-element&#38;quot;&#38;gt;
    &#38;lt;/li&#38;gt;
    &#38;lt;li&#38;gt;
    &#38;lt;/li&#38;gt;
&#38;lt;/ul&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Base on Chris' suggestion, here are the two functions I added to my functions.php file:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function add_markup_cat($output) { // add a class to cat-item
    return preg_replace(&#38;#39;/cat-item/&#38;#39;, &#38;#39;cat-item cat-item-first&#38;#39;, $output, 1);
}
add_filter(&#38;#39;wp_list_categories&#38;#39;, &#38;#39;add_markup_cat&#38;#39;);

function add_markup_page($output) { // add a class to page-item
    return preg_replace(&#38;#39;/page_item/&#38;#39;, &#38;#39;page_item page-item-first&#38;#39;, $output, 1);
}
add_filter(&#38;#39;wp_list_pages&#38;#39;, &#38;#39;add_markup_page&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Thanks for the hints.&#60;/p&#62;
&#60;p&#62;Pat
&#60;/p&#62;</description>
</item>
<item>
<title>Baudesign on "First element in a list: class="cat-item-first""</title>
<link>http://themeshaper.com/forums/topic/first-element-in-a-list-classcat-item-first#post-6788</link>
<pubDate>Tue, 29 Sep 2009 03:38:03 +0000</pubDate>
<dc:creator>Baudesign</dc:creator>
<guid isPermaLink="false">6788@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Chris, don't be sorry for the delay, my God, you do this on your own time free of charge! Family first, always.&#60;/p&#62;
&#60;p&#62;That being said, this is exactly what I was trying to achieve! Thank you very much. You rule, really.&#60;/p&#62;
&#60;p&#62;Pat
&#60;/p&#62;</description>
</item>
<item>
<title>Chris on "First element in a list: class="cat-item-first""</title>
<link>http://themeshaper.com/forums/topic/first-element-in-a-list-classcat-item-first#post-6775</link>
<pubDate>Mon, 28 Sep 2009 20:24:03 +0000</pubDate>
<dc:creator>Chris</dc:creator>
<guid isPermaLink="false">6775@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Hi Pat,&#60;/p&#62;
&#60;p&#62;sorry for this delay .. my family kept me busy over the weekend.&#60;/p&#62;
&#60;p&#62;Here is your solution .. put this code in your child theme's functions.php:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function add_markup($output) {
    return preg_replace(&#38;#39;/cat-item/&#38;#39;, &#38;#39;cat-item cat-item-first&#38;#39;, $output, 1);
}
add_filter(&#38;#39;wp_list_categories&#38;#39;, &#38;#39;add_markup&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Chris
&#60;/p&#62;</description>
</item>
<item>
<title>Baudesign on "First element in a list: class="cat-item-first""</title>
<link>http://themeshaper.com/forums/topic/first-element-in-a-list-classcat-item-first#post-6726</link>
<pubDate>Fri, 25 Sep 2009 20:24:37 +0000</pubDate>
<dc:creator>Baudesign</dc:creator>
<guid isPermaLink="false">6726@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Thanks Chris,&#60;/p&#62;
&#60;p&#62;I use WP in French. It is the default localized &#34;Catégories&#34; widget in the &#34;Primary Aside&#34; column. I suppose that it would therefore be the &#34;Categories&#34; widget. The reason I am trying to achieve this is that I want to apply a specific style to this first element in the list: no border top, whereas all the others would have this &#34;border top&#34;.&#60;/p&#62;
&#60;p&#62;Thanks for your time Chris.&#60;/p&#62;
&#60;p&#62;Pat
&#60;/p&#62;</description>
</item>
<item>
<title>Chris on "First element in a list: class="cat-item-first""</title>
<link>http://themeshaper.com/forums/topic/first-element-in-a-list-classcat-item-first#post-6722</link>
<pubDate>Fri, 25 Sep 2009 19:48:50 +0000</pubDate>
<dc:creator>Chris</dc:creator>
<guid isPermaLink="false">6722@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Hi Pat,&#60;/p&#62;
&#60;p&#62;will take a look at it tomorrow .. which widget is creating your list?&#60;/p&#62;
&#60;p&#62;Chris
&#60;/p&#62;</description>
</item>
<item>
<title>Baudesign on "First element in a list: class="cat-item-first""</title>
<link>http://themeshaper.com/forums/topic/first-element-in-a-list-classcat-item-first#post-6717</link>
<pubDate>Fri, 25 Sep 2009 16:57:42 +0000</pubDate>
<dc:creator>Baudesign</dc:creator>
<guid isPermaLink="false">6717@http://themeshaper.com/forums/</guid>
<description>&#60;p&#62;Hi everyone,&#60;/p&#62;
&#60;p&#62;The more I play with Thematic, the better I like it. My first post here.&#60;/p&#62;
&#60;p&#62;I would like to add a class to the first item in a list, in my sidebar, class=&#34;cat-item-first&#34;, like so:&#60;/p&#62;
&#60;ul&#62;
&#38;lt;li class=&#34;cat-item cat-item-first cat-item-4&#34;&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;li class=&#34;cat-item cat-item-5&#34;&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;li class=&#34;cat-item cat-item-6&#34;&#38;gt;&#60;/p&#62;
&#60;p&#62;&#38;lt;li class=&#34;cat-item cat-item-7&#34;&#38;gt;&#60;/p&#62;
&#60;p&#62;[...]
&#60;/ul&#62;
&#60;p&#62;This class definition comes from the &#34;classes.php&#34; file, but I do not want to change anything in the wordpress core files. I would like to make this change in my theme directory, and I do not know how. Would there be a function that would allow me to do such a thing?&#60;/p&#62;
&#60;p&#62;Thanks for any tip about how to do this.&#60;/p&#62;
&#60;p&#62;Pat
&#60;/p&#62;</description>
</item>

</channel>
</rss>

