<?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 Garage &#187; Code Snippets</title>
	<atom:link href="http://wpgarage.com/category/code-snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpgarage.com</link>
	<description>wordpress tricks, hacks, and tips</description>
	<lastBuildDate>Wed, 16 Nov 2011 14:36:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to link author image to their previous posts in WordPress</title>
		<link>http://wpgarage.com/code-snippets/how-to-link-author-image-to-their-previous-posts-in-wordpress/</link>
		<comments>http://wpgarage.com/code-snippets/how-to-link-author-image-to-their-previous-posts-in-wordpress/#comments</comments>
		<pubDate>Tue, 31 May 2011 06:15:48 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">?p=1031</guid>
		<description><![CDATA[<p>It seemed so simple and straightforward to link an author&#8217;s image to their page of previous posts like http://wpgarage.com/author/Rebecca/.&#160;But for some reason I couldn&#8217;t find the solution easily with the default WordPress template tags. Template tags that I had used last time I needed this functionality were deprecated. Here&#8217;s what I did: First, I set [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-link-author-image-to-their-previous-posts-in-wordpress/">How to link author image to their previous posts in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/how-to-link-author-image-to-their-previous-posts-in-wordpress/" data-url="http://illum.in/n5ETzL" data-text="How to link author image to their previous posts in WordPress" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/how-to-link-author-image-to-their-previous-posts-in-wordpress/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/how-to-link-author-image-to-their-previous-posts-in-wordpress/"></g:plusone></div></div><p>It seemed so simple and straightforward to link an author&#8217;s image to their page of previous posts like http://wpgarage.com/author/Rebecca/.&nbsp;But for some reason I couldn&#8217;t find the solution easily with the default <a href="http://codex.wordpress.org/Template_Tags">WordPress template tags</a>. Template tags that I had used last time I needed this functionality were deprecated.<br />
<a href="http://wpgarage.com/wp-content/uploads/2011/05/profile.png"><img title="profile" src="http://wpgarage.com/wp-content/uploads/2011/05/profile-e1306420276233.png" alt="" width="450" height="101"></a></p>
<p><strong>Here&#8217;s what I did:</strong></p>
<ol>
<li>First, I set up the author image using the <a href="http://wordpress.org/extend/plugins/sem-author-image/">Author Image plugin</a> to give our client an easy way to manage thumbnails of each author from the user&#8217;s profile settings.</li>
<li>Then I started looking for a way to link the author&#8217;s image to their archive. When I couldn&#8217;t find an easy answer in the WordPress template tags, I remembered that WPGarage has that feature in the footer area of each post! So I checked out the code of WPGlide theme (the theme we use on this site by <a href="https://www.e-junkie.com/ecom/gb.php?ii=662749&amp;c=ib&amp;aff=16393&amp;cl=11384">Solostream</a>), found the code I needed and modified it.Here&#8217;s the code I used:</li>
</ol>
<p>&lt;a href=&#8221;&lt;?php bloginfo(&#8216;url&#8217;); ?&gt;/author/&lt;?php  the_author_meta(&#8216;user_login&#8217;); ?&gt;/&#8221;&gt; <strong>&lt;?php the_author_image();  ?&gt; </strong>&lt;/a&gt;</p>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-link-author-image-to-their-previous-posts-in-wordpress/">How to link author image to their previous posts in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/how-to-link-author-image-to-their-previous-posts-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Allow Editor access level to add users in WordPress</title>
		<link>http://wpgarage.com/code-snippets/allow-editor-access-level-to-add-users-in-wordpress/</link>
		<comments>http://wpgarage.com/code-snippets/allow-editor-access-level-to-add-users-in-wordpress/#comments</comments>
		<pubDate>Sun, 29 May 2011 08:23:04 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">?p=1020</guid>
		<description><![CDATA[<p>Recently, a client asked us to allow editors to add users on their WordPress site. They wanted this feature so that the site managers wouldn&#8217;t be tempted to click on any of the settings, and possibly mess something up. I know this is super specific but it did come up for us so maybe it [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/allow-editor-access-level-to-add-users-in-wordpress/">Allow Editor access level to add users in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/allow-editor-access-level-to-add-users-in-wordpress/" data-url="http://illum.in/pyCoBL" data-text="Allow Editor access level to add users in WordPress" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/allow-editor-access-level-to-add-users-in-wordpress/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/allow-editor-access-level-to-add-users-in-wordpress/"></g:plusone></div></div><p>Recently, a client asked us to allow editors to add users on their WordPress site. They wanted this feature so that the site managers wouldn&#8217;t be tempted to click on any of the settings, and possibly mess something up. I know this is super specific but it did come up for us so maybe it will be relevant for you.</p>
<p>Here&#8217;s what I did:</p>
<ol>
<li>Install and activate the <a href="http://wordpress.org/extend/plugins/members/">Members Plugin</a></li>
<li>Go to Settings &gt; Members Components and activate the Edit Roles component<br />
<a href="http://wpgarage.com/wp-content/uploads/2011/05/roles.png"><img title="roles" src="http://wpgarage.com/wp-content/uploads/2011/05/roles-e1306417148772.png" alt="" width="450" height="382" /></a></li>
<li>Go to Users &gt; Roles. Click on Editor. In the options panel, check off create_users, edit_users, and delete_users.<br />
<img title="capabilities" src="http://wpgarage.com/wp-content/uploads/2011/05/capabilities-e1306417194666.png" alt="" width="450" height="353" /></li>
<li>Add <a href="http://wordpress.stackexchange.com/questions/4479/editor-can-create-any-new-user-except-administrator">this code</a> into your funcitons.php file.</li>
<li>Test it out.</li>
<li>That&#8217;s it.</li>
</ol>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/allow-editor-access-level-to-add-users-in-wordpress/">Allow Editor access level to add users in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/allow-editor-access-level-to-add-users-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The ultimate guide to embedding HTML and iframes in WordPress &#8211; part 2</title>
		<link>http://wpgarage.com/code-snippets/embedding-html-and-iframes-in-wordpress-2/</link>
		<comments>http://wpgarage.com/code-snippets/embedding-html-and-iframes-in-wordpress-2/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 11:47:11 +0000</pubDate>
		<dc:creator>Miriam Schwab</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">?p=944</guid>
		<description><![CDATA[<p>Recently, I wrote about how WordPress users can easily add media like YouTube videos to posts and pages by just inserting the URL of the page the media is on. But that functionality was limited to sites that are oEmbed providers. We are still left with the problem of not being able to insert non-oEmbed [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/embedding-html-and-iframes-in-wordpress-2/">The ultimate guide to embedding HTML and iframes in WordPress &#8211; part 2</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/embedding-html-and-iframes-in-wordpress-2/" data-url="http://illum.in/qcaqm9" data-text="The ultimate guide to embedding HTML and iframes in WordPress &#8211; part 2" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/embedding-html-and-iframes-in-wordpress-2/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/embedding-html-and-iframes-in-wordpress-2/"></g:plusone></div></div><p>Recently, I wrote about how <a title="The ultimate guide to embedding HTML and iframes in WordPress" href="tips/embed-html-iframes-wordpress/">WordPress users can easily add media like YouTube videos</a> to posts and pages by just inserting the URL of the page the media is on. But that functionality was limited to sites that are <a title="oEmbed" href="http://www.oembed.com/">oEmbed</a> providers. We are still left with the problem of not being able to insert non-oEmbed iframes in WordPress, like Google Forms for example. If you try to insert a Google Form in the WordPress editor, you may find that all of the HTML is stripped out and you&#8217;re just left with a lonely &#8220;Loading&#8230;&#8221; on your page.</p>
<p>Well, there&#8217;s a solution. There&#8217;s an awesome thread on WordPress StackExchange with a <a title="Best Collection of Code for your functions.php file" href="http://wordpress.stackexchange.com/questions/1567/best-collection-of-code-for-your-functions-php-file?page=2&amp;tab=votes#tab-top" target="_blank">collection of code for the functions.php file</a>, including the following:</p>
<p><code>// make TinyMCE allow iframes<br />
add_filter('tiny_mce_before_init', create_function( '$a',<br />
'$a["extended_valid_elements"] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]"; return $a;') );</code></p>
<p>Copy and paste the code into your WordPress functions.php file, and now you can embed any ol&#8217; iframe you want in your WordPress editor, and it won&#8217;t get stripped out!</p>
<p>Happy embedding!</p>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/embedding-html-and-iframes-in-wordpress-2/">The ultimate guide to embedding HTML and iframes in WordPress &#8211; part 2</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/embedding-html-and-iframes-in-wordpress-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to remove the link to parent pages when using wp_list_pages in WordPress navigation</title>
		<link>http://wpgarage.com/code-snippets/how-to-remove-the-link-to-parent-pages-when-using-wp_list_pages-in-wordpress-navigation/</link>
		<comments>http://wpgarage.com/code-snippets/how-to-remove-the-link-to-parent-pages-when-using-wp_list_pages-in-wordpress-navigation/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 15:11:31 +0000</pubDate>
		<dc:creator>David Stein</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[digitalpoint]]></category>
		<category><![CDATA[Navigation bar]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">?p=810</guid>
		<description><![CDATA[<p>Recently I was working on a client&#8217;s WordPress website and he made an interesting request, that I am actually surprised we don&#8217;t see more often. He wanted the top links on his navigation bar to not be live links, and only the sub-pages should actually link to pages on his site. In this case the [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-remove-the-link-to-parent-pages-when-using-wp_list_pages-in-wordpress-navigation/">How to remove the link to parent pages when using wp_list_pages in WordPress navigation</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/how-to-remove-the-link-to-parent-pages-when-using-wp_list_pages-in-wordpress-navigation/" data-url="http://illum.in/n9egrz" data-text="How to remove the link to parent pages when using wp_list_pages in WordPress navigation" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/how-to-remove-the-link-to-parent-pages-when-using-wp_list_pages-in-wordpress-navigation/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/how-to-remove-the-link-to-parent-pages-when-using-wp_list_pages-in-wordpress-navigation/"></g:plusone></div></div><p>Recently I was working on a client&#8217;s WordPress website and he made an interesting request, that I am actually surprised we don&#8217;t see more often. He wanted the top links on his navigation bar to not be live links, and only the sub-pages should actually link to pages on his site.</p>
<p>In this case the top page on the navigation bar was called Galleries, which is the parent page for sub-pages with galleries for wedding photos, wedding videos etc. He didn&#8217;t want a main galleries page, but instead he wanted it to be a kind of folder for categorizing the various galleries he was going to have on other pages in his site.</p>
<p>Since we are using wp_list_pages, we can&#8217;t unlink each page on an individual basis since the navigation bar is dynamically formed. So I needed some way to keep using wp_list_pages so that the client can control the navigation bar, but unlink the top Galleries page.</p>
<p>I found the answer on what I think is one of the best forums around of internet and computer experts and people who are eager to help one another: <a title="Digital Point Forums" href="http://forums.digitalpoint.com/" target="_blank">Digital Point</a>.</p>
<p>After a few suggestions from people on the forums, <a title="Navigation bar links" href="http://forums.digitalpoint.com/showthread.php?t=1843887#post14451958" target="_blank">I finally got an answer</a> from the awesome <a title="bvraghav" href="http://forums.digitalpoint.com/member.php?u=432200">bvraghav</a>.</p>
<p>In the header.php section of the file I embeded a javascript code that looked like this:<br />
<code><br />
&lt;script type="text/javascript"&gt;<br />
jQuery(function($) {<br />
$("li.page-item-283").children("a").attr('href', "javascript:void(0)");<br />
});<br />
&lt;/script&gt;<br />
&lt;script type="text/javascript"&gt;jQuery(function($) {    $("li.page-item-283").children("a").attr('href', "javascript:void(0)");});&lt;/script&gt;<br />
</code><br />
This is how it works:</p>
<ul>
<li> The  jquery (a javascript framework) is used to replace the value of href  property in the required html node ( &lt;a  href=&#8221;your-galleries-link&#8221;&gt;&#8230;. &lt;/a&gt; in this case) with  &#8220;javascript:void(0)&#8221;.  Looks like this:  jQuery(function($) {</li>
</ul>
<ul>
<li>The following code selects the li element with: $(&#8220;li.page-item-283&#8243;). In this case 283 the page number that we want to void the link for (in our case the top Galleries page).</li>
</ul>
<ul>
<li>The next part is the  children function which selects all immediate children with tag a: children(&#8220;a&#8221;) . This relates t<span style="color: red;"><span style="color: #000000;">he child pages to the gallery pages and keeps their links. </span><br />
</span></li>
</ul>
<ul>
<li>After this I had to change the attribute href to &#8220;javascript:void(0)&#8221;, which looks like this:  .attr(&#8216;href&#8217;, &#8220;javascript:void(0)&#8221;); This turns th<span style="color: red;"><span style="color: #000000;">e gallery link into void so it won&#8217;t direct anywhere.</span><br />
</span></li>
</ul>
<p>All this comes together to look like the code above.</p>
<p>If you want to make all top level links unlinked, use the following code:</p>
<pre>&lt;script type="text/javascript"&gt;
jQuery(function($) {
    $("li.page_item").children("a").attr('href', "javascript:void(0)"); });
&lt;/script&gt;</pre>
<p>What I&#8217;m wondering is if the new WordPress navigation system allows users to include items in navigation bars that don&#8217;t actually lead anywhere. Anyone know?</p>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-remove-the-link-to-parent-pages-when-using-wp_list_pages-in-wordpress-navigation/">How to remove the link to parent pages when using wp_list_pages in WordPress navigation</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/how-to-remove-the-link-to-parent-pages-when-using-wp_list_pages-in-wordpress-navigation/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Automatic Plugin Upgrade broken after WordPress 2.9.2 and some fixes</title>
		<link>http://wpgarage.com/code-snippets/automatic-plugin-upgrade-broken-after-wordpress-2-9-2-and-some-fixes/</link>
		<comments>http://wpgarage.com/code-snippets/automatic-plugin-upgrade-broken-after-wordpress-2-9-2-and-some-fixes/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 06:43:25 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[automatic upgrade]]></category>
		<category><![CDATA[find content directory]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[remove old plugin]]></category>

		<guid isPermaLink="false">?p=712</guid>
		<description><![CDATA[<p>After manually upgrading one of our client&#8217;s sites to WordPress 2.9.2. we noticed that the only thing that went awry was the automatic plugin upgrade. WP asked me for the FTP information, and then gave me this error message: Cannot find Content directory (WP-Content) The first solution I found suggested to make sure that all [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/automatic-plugin-upgrade-broken-after-wordpress-2-9-2-and-some-fixes/">Automatic Plugin Upgrade broken after WordPress 2.9.2 and some fixes</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/automatic-plugin-upgrade-broken-after-wordpress-2-9-2-and-some-fixes/" data-url="http://illum.in/qlQzSj" data-text="Automatic Plugin Upgrade broken after WordPress 2.9.2 and some fixes" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/automatic-plugin-upgrade-broken-after-wordpress-2-9-2-and-some-fixes/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/automatic-plugin-upgrade-broken-after-wordpress-2-9-2-and-some-fixes/"></g:plusone></div></div><div>
<div>
<p>After manually upgrading one of our client&#8217;s sites to WordPress 2.9.2. we noticed that the only thing that went awry was the automatic plugin upgrade.</p>
<p>WP asked me for the FTP information, and then gave me this error message:</p>
<p><strong>Cannot find Content directory (WP-Content)</strong></p>
<p>The first solution I found suggested to make sure that all the necessary folders and files had a permission level of 755 or 777 (wp-content folder, plugin folder, upgrade folder) and to  add the following to the wp-config file as indicated by<a href="http://www.hui-wang.info/2009/06/unable-to-locate-wordpress-content-directory-wp-content/"> Hui Wang</a>:</p>
<div>
<div>
<blockquote><p>if(is_admin()) {<br />
add_filter(&#8216;filesystem_method&#8217;, create_function(&#8216;$a&#8217;, &#8216;return &#8220;direct&#8221;;&#8217; ));<br />
define( &#8216;FS_CHMOD_DIR&#8217;, 0751 );<br />
}</p></blockquote>
</div>
</div>
<p>But,  this caused the plugin list to show duplicate plugins &#8211; the older version and the upgraded version of the plugin. For some reason, it wasn&#8217;t deleting the old files.</p>
<p>Then, I tried deleting the code from the wp-config and trying again.  This time, I got a different error (don&#8217;t ask me why):</p>
<p><strong>Could not remove the old plugin</strong></p>
<p><strong>Plugin upgrade Failed</strong></p>
<p>So I found this<a href="http://wordpress.org/support/topic/266008"> fix from the Support Forum</a><strong> </strong>which seems to have fixed everything for now. <strong> </strong></p>
<div>
<div>
<div>
<div>
<blockquote><p>1. Make sure your wp-config.php file is chmodded to 0644.</p>
<p>2. Also make sure your .htaccess file is protecting the wp-config file using these lines:</p>
<p>&lt;Files wp-config.php&gt;<br />
order allow,deny<br />
deny from all<br />
&lt;/Files&gt;</p>
<p>3. Backup your wp-config.php file.</p>
<p>4. Edit your wp-config.php file putting these lines in underneath &lt;?php:</p>
<p>define(&#8216;FS_METHOD&#8217;, &#8216;ftpsockets&#8217;);<br />
define(&#8216;FTP_BASE&#8217;, &#8216;/path/to/wordpress/&#8217;);<br />
define(&#8216;FTP_CONTENT_DIR&#8217;, &#8216;/path/to/wordpress/wp-content/&#8217;);<br />
define(&#8216;FTP_PLUGIN_DIR &#8216;, &#8216;/path/to/wordpress/wp-content/plugins/&#8217;);<br />
define(&#8216;FTP_USER&#8217;, &#8216;username&#8217;);<br />
define(&#8216;FTP_PASS&#8217;, &#8216;password&#8217;);<br />
define(&#8216;FTP_HOST&#8217;, &#8216;<a href="http://ftp.example.org/" target="_blank">ftp.example.org</a>&#8216;);</p></blockquote>
<p>Crossing our fingers that the automatic upgrade to version 3.0 will go smoothly!</p>
</div>
</div>
</div>
</div>
</div>
</div>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/automatic-plugin-upgrade-broken-after-wordpress-2-9-2-and-some-fixes/">Automatic Plugin Upgrade broken after WordPress 2.9.2 and some fixes</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/automatic-plugin-upgrade-broken-after-wordpress-2-9-2-and-some-fixes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to create an archive based on custom fields, not publish date in WordPress</title>
		<link>http://wpgarage.com/code-snippets/how-to-create-an-archive-based-on-custom-fields-not-publish-date-in-wordpress/</link>
		<comments>http://wpgarage.com/code-snippets/how-to-create-an-archive-based-on-custom-fields-not-publish-date-in-wordpress/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 13:06:11 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[archives]]></category>
		<category><![CDATA[custom field]]></category>
		<category><![CDATA[dates]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[publish dates]]></category>

		<guid isPermaLink="false">?p=699</guid>
		<description><![CDATA[<p>We recently launched a site called theforgottenletters.org, an incredible project dedicated to translating the Holocaust-era letters of Ralph Schwab from German to English. While building the site, we needed to archive the letters based on the dates the letters were written, not when we publish them to the site. First, I tried this tutorial: How [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-create-an-archive-based-on-custom-fields-not-publish-date-in-wordpress/">How to create an archive based on custom fields, not publish date in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/how-to-create-an-archive-based-on-custom-fields-not-publish-date-in-wordpress/" data-url="http://illum.in/oU47tn" data-text="How to create an archive based on custom fields, not publish date in WordPress" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/how-to-create-an-archive-based-on-custom-fields-not-publish-date-in-wordpress/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/how-to-create-an-archive-based-on-custom-fields-not-publish-date-in-wordpress/"></g:plusone></div></div><p>We recently launched a site called <a href="http://theforgottenletters.org">theforgottenletters.org</a>, an incredible project dedicated to translating the Holocaust-era letters of Ralph Schwab from German to English. While building the site, we needed to archive the letters based on the dates the letters were written, not when we publish them to the site.</p>
<p>First, I tried this <a href="http://www.problogdesign.com/wordpress/how-to-make-a-wordpress-events-list/">tu</a><a href="http://www.problogdesign.com/wordpress/how-to-make-a-wordpress-events-list/">torial: How To Make a WordPress Events List</a> and <a href="plugins/wordpress-calendar-plugins/">calendar plugins</a>, but the tutorial wasn&#8217;t comprehensive enough and the plugins were too complex to start messing with.</p>
<p><strong>The solution</strong></p>
<p>I found this wonderful <a href="http://matth.eu/wordpress-date-field-plugin">date field plugin</a> which lets  you sort posts by the date entered in the custom fields.  Here&#8217;s what I did:</p>
<p>1. Upload the plugin and activate it</p>
<p>2. Opened the lettersarchive.php page template I created and added a query. The query checks for posts in the Letters category that have a date filled in and the orders it from oldest to newest.</p>
<p><strong>&lt;?php query_posts(&#8216;category_name=letters&amp;meta_key=date_value&amp;orderby=meta_value&amp;order=DESC&#8217;); ?&gt;</strong></p>
<p>3. I replaced a typical date function within the loop &lt;?php the_time(&#8216;j M Y&#8217;); ?&gt; with</p>
<p><strong>&lt;?php echo date(&#8220;l jS \of F Y&#8221;, get_post_meta($post-&gt;ID, &#8216;date_value&#8217;, true));?&gt;</strong></p>
<p>4. I created a new post,  assigned it to the Letters category, and selected a date from the date picker box that now appears below the editing box in the post area.<br />
<img class="alignnone size-full wp-image-701" title="adddateinfo" src="http://wpgarage.com/wp-content/uploads/2010/04/adddateinfo.png" alt="" width="309" height="120" /></p>
<p>I noticed that the Date Field plugin only lets you select a date up to 5 years ago  so I had to hack the plugin file on line 125 to  reflect selecting dates from 80 years ago.</p>
<p>for($currentyear = date(&#8216;Y&#8217;)<strong> &#8211; 80</strong>; $currentyear &lt;= date(Y) +5;$currentyear +=1)</p>
<p>Here&#8217;s a screenshot of the archive from <a href="http://theforgottenletters.org">The Forgotten Letters</a> site.</p>
<p><img class="alignnone size-full wp-image-702" title="lettersscreen" src="http://wpgarage.com/wp-content/uploads/2010/04/lettersscreen.png" alt="" width="250" height="191" /></p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">http://www.problogdesign.com/wordpress/how-to-make-a-wordpress-events-list/#comment-16409</div>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-create-an-archive-based-on-custom-fields-not-publish-date-in-wordpress/">How to create an archive based on custom fields, not publish date in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/how-to-create-an-archive-based-on-custom-fields-not-publish-date-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to list Pages with custom fields in 2 columns in WordPress</title>
		<link>http://wpgarage.com/code-snippets/how-to-list-pages-with-custom-fields-in-2-columns-in-wordpress/</link>
		<comments>http://wpgarage.com/code-snippets/how-to-list-pages-with-custom-fields-in-2-columns-in-wordpress/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 11:51:11 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[columns]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[Pages]]></category>

		<guid isPermaLink="false">?p=695</guid>
		<description><![CDATA[<p>Recently, I needed to list all subpages of a parent page.  I also needed to display custom fields below each subpage. And, on top of that, the list needed to be 2 columns. I found a solution for simply listing the pages in 2 columns, but it did not suggest how to modify the code [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-list-pages-with-custom-fields-in-2-columns-in-wordpress/">How to list Pages with custom fields in 2 columns in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/how-to-list-pages-with-custom-fields-in-2-columns-in-wordpress/" data-url="http://illum.in/oWCm4j" data-text="How to list Pages with custom fields in 2 columns in WordPress" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/how-to-list-pages-with-custom-fields-in-2-columns-in-wordpress/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/how-to-list-pages-with-custom-fields-in-2-columns-in-wordpress/"></g:plusone></div></div><p>Recently, I needed to list all subpages of a parent page.  I also needed to display custom fields below each subpage. And, on top of that, the list needed to be 2 columns.</p>
<p>I found a <a href="http://www.livexp.net/wordpress/display-list-of-wordpress-pages-in-two-columns.html">solution</a> for simply listing the pages in 2 columns, but it did not suggest how to modify the code to include custom fields.</p>
<p>So, thanks to our coding hero <a href="http://marksw.com/wordpress/">Mark Kaplun</a> who supplied the below code, although he admits it&#8217;s a &#8220;dirty hack&#8221;. The sort_column is so that MyPageOrder would work properly for this listing.</p>
<blockquote><p>&lt;?php<br />
$args = array(<br />
&#8216;post_type&#8217; =&gt; &#8216;page&#8217;,<br />
&#8216;numberposts&#8217; =&gt; 40,<br />
&#8216;sort_column&#8217; =&gt; &#8216;menu_order&#8217;,<br />
&#8216;child_of&#8217; =&gt; 84 // any parent<br />
);<br />
$attachments = get_pages($args);<br />
//print_r(&#8220;attachements:&#8221; . $attachements);<br />
echo &#8216;&lt;div style=&#8221;float: left; margin: 0 10px 0 0;&#8221;&gt;&#8217;;<br />
?&gt;</p>
<p>&lt;?php<br />
for ($i =0; $i&lt;count($attachments)/2; $i++) {<br />
$post = $attachments[$i];<br />
//    foreach ($attachments as $post)  { ?&gt;</p>
<p>&lt;a href=&#8221;&lt;?php echo get_permalink($post-&gt;ID) ?&gt;&#8221; rel=&#8221;bookmark&#8221;&gt;&lt;?php echo $post-&gt;post_title; ?&gt;&lt;/a&gt;<br />
&lt;?php if(get_post_meta($post-&gt;ID, &#8220;NameofCustomField&#8221;, true)) { ?&gt;<br />
&lt;?php<br />
echo get_post_meta($post-&gt;ID, &#8220;NameofCustomField&#8221;, true);<br />
}<br />
?&gt;<br />
&lt;?php } ?&gt;<br />
&lt;/div&gt;<br />
&lt;?php<br />
echo &#8216;&lt;div style=&#8221;float: left; margin: 0 10px 0 0;&#8221;&gt;&#8217;;<br />
for (; $i&lt;count($attachments); $i++) {<br />
$post = $attachments[$i];<br />
//    foreach ($attachments as $post)  { ?&gt;</p>
<p>&lt;a href=&#8221;&lt;?php echo get_permalink($post-&gt;ID) ?&gt;&#8221; rel=&#8221;bookmark&#8221;&gt;&lt;?php echo $post-&gt;post_title; ?&gt;&lt;/a&gt;<br />
&lt;?php if(get_post_meta($post-&gt;ID, &#8220;PracticeArea&#8221;, true)) { ?&gt;<br />
&lt;?php<br />
echo get_post_meta($post-&gt;ID, &#8220;PracticeArea&#8221;, true);<br />
}<br />
?&gt;<br />
&lt;?php } ?&gt;<br />
&lt;/div&gt;</p></blockquote>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/how-to-list-pages-with-custom-fields-in-2-columns-in-wordpress/">How to list Pages with custom fields in 2 columns in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/how-to-list-pages-with-custom-fields-in-2-columns-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to get around WordPress&#8217; limitation on uploading certain file types</title>
		<link>http://wpgarage.com/code-snippets/changing-wordpress-list-accepted-file-types-for-upload/</link>
		<comments>http://wpgarage.com/code-snippets/changing-wordpress-list-accepted-file-types-for-upload/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 21:19:13 +0000</pubDate>
		<dc:creator>Miriam Schwab</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[file management]]></category>
		<category><![CDATA[functions.php]]></category>

		<guid isPermaLink="false">?p=674</guid>
		<description><![CDATA[<p>One of our clients needed to upload files via their admin, and kept getting the following error message: “File type does not meet security guidelines. Try another.” This was something new to us, and after doing some research we discovered that WordPress only allows users to upload certain types of files, and any files that [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/changing-wordpress-list-accepted-file-types-for-upload/">How to get around WordPress&#8217; limitation on uploading certain file types</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/changing-wordpress-list-accepted-file-types-for-upload/" data-url="http://illum.in/qOoTto" data-text="How to get around WordPress&#8217; limitation on uploading certain file types" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/changing-wordpress-list-accepted-file-types-for-upload/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/changing-wordpress-list-accepted-file-types-for-upload/"></g:plusone></div></div><p>One of our clients needed to upload files via their admin, and kept getting the following error message: “File type does not meet security guidelines. Try another.”</p>
<p>This was something new to us, and after doing some research we discovered that WordPress only allows users to upload certain types of files, and any files that are not part of that list cannot be uploaded through the admin. Here’s the list of <a href="http://en.support.wordpress.com/accepted-filetypes/">accepted WordPress files types</a>.</p>
<p>It turns out that the list of accepted file types is found in <code>wp-includes/functions.php</code>. Since we don’t want to modify WordPress core files, we need a solution like a plugin in order to get around this limitation.</p>
<p>Chris Meller has a solution that involves adding some code to your functions.php file in your theme directory. He also explains how to remove file types from the list of allowed files types.</p>
<p>For more info on how to do this, see this post on his blog: <a href="http://chrismeller.com/2007/07/modifying-allowed-upload-types-in-wordpress/">Modifying Allowed Upload Types in WordPress</a>.</p>
<p>Thanks to <a title="Mark Kaplun's blog" href="http://marksw.com/wordpress/">Mark Kaplun</a> for helping us find this solution.</p>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/changing-wordpress-list-accepted-file-types-for-upload/">How to get around WordPress&#8217; limitation on uploading certain file types</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/changing-wordpress-list-accepted-file-types-for-upload/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Display sticky post and exclude it from recent posts list in WordPress</title>
		<link>http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/</link>
		<comments>http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 13:30:03 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[exclude]]></category>
		<category><![CDATA[recent posts]]></category>
		<category><![CDATA[sticky posts]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">?p=592</guid>
		<description><![CDATA[<p>We were working on a WordPress site that needed to display a sticky post at the top of the blog page with one style, and then below it a list of the most recent posts with a completely different style. I realize that you can just style the sticky post using the sticky-related classes provided [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/">Display sticky post and exclude it from recent posts list in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/" data-url="http://illum.in/mVbXEl" data-text="Display sticky post and exclude it from recent posts list in WordPress" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/"></g:plusone></div></div><p>We were working on a WordPress site that needed to display a sticky post at the top of the blog page with one style, and then below it a list of the most recent posts with a completely different style.</p>
<p>I realize that you can just style the sticky post using the sticky-related classes provided by WordPress:</p>
<blockquote><p>&lt;div &lt;?php post_class(); ?&gt;&gt; and .sticky class</p></blockquote>
<p>but I needed to have design elements appear in between the sticky post and the rest of the recent posts, and the recent posts needed to have a completely different design than the sticky. Therefore I decided to go with a 2 loop solution. Once we were using two loops, we had to also make sure that sticky post did not repeat itself and appear in the list of recent posts following it.</p>
<p><a href="http://www.nathanrice.net/blog/definitive-sticky-posts-guide-for-wordpress-27/">Nathan Rice</a> provides a lot of useful information about sticky posts but I couldn&#8217;t get the code he posted to work properly. So I went on a hunt to figure it out.</p>
<h2>How to display a sticky post</h2>
<p>The best solution I found for how to display a WordPress sticky post was a <a href="http://justintadlock.com/archives/2009/03/28/get-the-latest-sticky-posts-in-wordpress#comment-113133">comment </a>by <cite title="http://www.ethymos.com.br"></cite><a title="Eduardo" rel="external nofollow" href="http://www.ethymos.com.br/">Eduardo</a> on Justin Tadlock&#8217;s post <a title="Get the latest sticky posts in WordPress" href="http://justintadlock.com/archives/2009/03/28/get-the-latest-sticky-posts-in-wordpress">Get the Latest Sticky Post</a>. He gave the following code:</p>
<blockquote><p>&lt;?php<br />
$sticky = get_option( &#8216;sticky_posts&#8217; );<br />
query_posts( array( &#8216;post__in&#8217; =&gt; $sticky, &#8216;caller_get_posts&#8217; =&gt; 1, &#8216;orderby&#8217; =&gt; ID, &#8216;showposts&#8217; =&gt; 2 ) );<br />
?&gt;<br />
&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;<br />
&lt;a href=&#8221;&lt;?php the_permalink(); ?&gt;&#8221; rel=&#8221;bookmark&#8221; title=&#8221;Permanent Link to &lt;?php the_title(); ?&gt;&#8221;&gt;<br />
&lt;?php endwhile;?&gt;</p>
<p>&lt;?php endif; ?&gt;</p></blockquote>
<p>It worked very nicely.</p>
<h2>How to exclude sticky posts from a list of recent posts</h2>
<p>I then wanted to show a list of 3 recent posts that excluded the post that had been defined as sticky. After many trials and errors with different solutions posted around the web, I finally found one that worked on the <a href="http://wordpress.org/support/topic/338776">WordPress Support Forum.</a></p>
<blockquote><p>&lt;?php $sticky = get_option(&#8216;sticky_posts&#8217;) ;</p>
<p>$post_to_exclude[] = $sticky[0];</p>
<p>$args=array(<br />
&#8216;caller_get_posts&#8217;=&gt;1,<br />
&#8216;showposts&#8217;=&gt;2,<br />
&#8216;post__not_in&#8217;=&gt; $post_to_exclude,<br />
);</p>
<p>query_posts($args); ?&gt;</p>
<p>&lt;h2&gt;&lt;a href=&#8221;&lt;?php the_permalink() ?&gt;&#8221;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt; &lt;/h2&gt;</p>
<p>&lt;?php while (have_posts()) : the_post();  ?&gt;</p>
<p>&lt;?php endwhile;?&gt;</p></blockquote>
<p>So there you have it: a workable way to have a WordPress sticky post with one style, and a list of recent posts excluding the sticky post with a completely different style below the sticky post.</p>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/">Display sticky post and exclude it from recent posts list in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to list the 4 latest posts with only one post per author in WordPress</title>
		<link>http://wpgarage.com/code-snippets/list-4-latest-posts-with-only-one-post-per-author/</link>
		<comments>http://wpgarage.com/code-snippets/list-4-latest-posts-with-only-one-post-per-author/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 13:05:00 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[author]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[recent posts]]></category>
		<category><![CDATA[sidebar]]></category>
		<category><![CDATA[thumbnails]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://wordpressgarage.com/code-snippets/list-4-latest-posts-with-only-one-post-per-author/</guid>
		<description><![CDATA[<p>Recently, one site we were working on needed a sidebar that would show the 4 most recent posts on the site. But here’s the catch: they wanted only one post per author. And, each author had to have the role of “author” as opposed to contributor or admin. The site in question is still in [...]</p><p>This post was originally published at <a href="http://wpgarage.com/code-snippets/list-4-latest-posts-with-only-one-post-per-author/">How to list the 4 latest posts with only one post per author in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:right;"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-counturl="http://wpgarage.com/code-snippets/list-4-latest-posts-with-only-one-post-per-author/" data-url="http://illum.in/pe07NY" data-text="How to list the 4 latest posts with only one post per author in WordPress" data-count="vertical" data-via="wpgarage" data-related="wpgarage"><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="http://www.facebook.com/plugins/like.php?href=http://wpgarage.com/code-snippets/list-4-latest-posts-with-only-one-post-per-author/&amp;layout=box_count&amp;show_faces=true&amp;width=50&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px !important; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://wpgarage.com/code-snippets/list-4-latest-posts-with-only-one-post-per-author/"></g:plusone></div></div><p>Recently, one site we were working on needed a sidebar that would show the 4 most recent posts on the site. But here’s the catch: they wanted only one post per author. And, each author had to have the role of “author” as opposed to contributor or admin.</p>
<p>The site in question is still in Beta, so I can’t give out the link yet. But here’s a snapshot to give you a better idea of what we were going for.</p>
<p><a href="wp-content/uploads/2009/09/wpgblogs.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="wpgblogs" src="http://wpgarage.com/wp-content/uploads/2009/09/wpgblogs_thumb.jpg" border="0" alt="wpgblogs" width="192" height="244" /></a></p>
<p>We also used the plugin <a href="http://wordpress.org/extend/plugins/user-photo/">User Photo</a> to show each author’s thumbnail, which I have come to love and recommend.</p>
<p>Thanks to <a href="http://www.marksw.com/blog/wordpress/">Mark Kaplun</a> for this great solution:</p>
<p>Open your Sidebar.php file and add the following:</p>
<p>Please note: this code uses the plugin Limit Posts to create excerpts. But you can substitute that snippet with any type of excerpt code.</p>
<p>&lt;?php $authors = get_users_of_blog(); ?&gt;</p>
<p>&lt;?php<br />
$latest_posts = array();<br />
foreach ( $authors as $author ) {<br />
$user = new WP_User( $author-&gt;ID );<br />
if ($user-&gt;has_cap(&#8216;level_7&#8242;))<br />
continue;<br />
$ps = get_posts(&#8216;numberposts=1&amp;post_type=post&amp;author=&#8217; . $author-&gt;ID . &#8216;&amp;cat=-9,-3&#8242;);<br />
foreach ($ps as $p) {<br />
$latest_posts[$p-&gt;post_date] = $p;<br />
}<br />
}<br />
krsort($latest_posts);<br />
?&gt;<br />
&lt;?php //query_posts(&#8216;author=&#8217; . $author-&gt;ID . &#8216;&amp;showposts=1&amp;cat=-9,-3&#8242;); ?&gt;<br />
&lt;?php<br />
$counter =0;<br />
foreach ($latest_posts as $post) {<br />
$counter++;<br />
if ($counter &gt; 4)<br />
break;<br />
setup_postdata($post);<br />
?&gt;</p>
<p>&lt;?php // while (have_posts()) : the_post(); ?&gt;</p>
<p>&lt;li&gt;<br />
&lt;?php userphoto_the_author_thumbnail(); ?&gt;<br />
&lt;span class=&#8221;blogauthor&#8221;&gt; &lt;?php the_author_posts_link(); ?&gt; &lt;/span&gt;<br />
&lt;div class=&#8221;blog&#8221;&gt;    &lt;a title=&#8221;Permanent Link to &lt;?php the_title(); ?&gt;&#8221; href=&#8221;&lt;?php the_permalink() ?&gt;&#8221; rel=&#8221;bookmark&#8221;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/div&gt;<br />
&lt;br /&gt;</p>
<p>&lt;?php  the_content_limit(&#8217;55,read more&#8217;); ?&gt; &lt;strong&gt;&lt;a title=&#8221;Permanent Link to &lt;?php the_title(); ?&gt;&#8221; href=&#8221;&lt;?php the_permalink() ?&gt;&#8221;&gt;Read more&lt;/a&gt;   &lt;/strong&gt;<br />
&lt;/li&gt;<br />
&lt;?php } ?&gt;</p>
<p>&lt;?php // }; ?&gt;</p>
<p>The End. Yay code!</p>
<p>This post was originally published at <a href="http://wpgarage.com/code-snippets/list-4-latest-posts-with-only-one-post-per-author/">How to list the 4 latest posts with only one post per author in WordPress</a> on <a href="http://wpgarage.com">WP Garage</a> - <a href="http://wpgarage.com">WP Garage - wordpress tricks, hacks, and tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/list-4-latest-posts-with-only-one-post-per-author/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

