<?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>Gabriel de Kadt &#187; WordPress</title>
	<atom:link href="http://www.lazydada.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lazydada.com</link>
	<description>Personal notes on Mac based web development and design.</description>
	<lastBuildDate>Tue, 30 Aug 2011 10:47:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Hard coding your site URL in WordPress</title>
		<link>http://www.lazydada.com/2011-07-29/hard-coding-your-site-url-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hard-coding-your-site-url-in-wordpress</link>
		<comments>http://www.lazydada.com/2011-07-29/hard-coding-your-site-url-in-wordpress/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 23:16:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=948</guid>
		<description><![CDATA[I discovered this handy feature on troubleshooting a login problem for a client of mine. If you swap your WP database between a development and production server at all regularly and don&#8217;t fancy editing your site URL and WordPress URL in the wp-options table each time (either directly or via the WP admin interface)&#8230; you [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered this handy feature on troubleshooting a login problem for a client of mine. </p>
<p>If you swap your WP database between a development and production server at all regularly and don&#8217;t fancy editing your site URL and WordPress URL in the  wp-options table each time (either directly or via the WP admin interface)&#8230; you can hard code it into the wp-config.php file! Tie this together with WordPress ability to keep this config file out of harms way in a directory above your WP install (ie out of your public_html directory) and you have an easy hands free file sync operation too.</p>
<p>Just add these two lines of code into wp-config.php:<br />
<code><br />
// hardcoding the domain<br />
define("WP_SITEURL","http://www.mysite.com");<br />
define("WP_HOME","http://www.mysite.com");<br />
</code></p>
<p>BTW &#8211; note the lack of trailing slashes on the URLs</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-07-29/hard-coding-your-site-url-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nice WordPress article in .Net</title>
		<link>http://www.lazydada.com/2011-07-25/nice-wordpress-article-in-net/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nice-wordpress-article-in-net</link>
		<comments>http://www.lazydada.com/2011-07-25/nice-wordpress-article-in-net/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 15:48:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=945</guid>
		<description><![CDATA[Nice article about WordPress in my favourite web design and develpment magazine (issue 217  of .NET). Usual stuff but well written without either speeding or jabbering. There&#8217;s a nice overview of Custom Menus, Multisite, Custom Post Formats, Custom Post types and Custom Taxonomies. WP Custom Heaven One thing I&#8217;d never heard of before was the new [...]]]></description>
			<content:encoded><![CDATA[<p>Nice article about WordPress in my favourite <a title="dot Net magazine" href="http://www.netmagazine.com/" target="_blank">web design and develpment magazine</a> (issue 217  of .NET). Usual stuff but well written without either speeding or jabbering.</p>
<p>There&#8217;s a nice overview of Custom Menus, Multisite, Custom Post Formats, Custom Post types and Custom Taxonomies.</p>
<h4>WP Custom Heaven</h4>
<p>One thing I&#8217;d never heard of before was the new ability in WordPress 3.x to enable custom background images to any post. Just add the following to your <tt>functions.php</tt> file:</p>
<pre class="brush: php; title: ; notranslate">add_custom_background();</pre>
<p>. Look up the codex for more. Aparently this allows admin users to change background image properties (as CSS) from within the appearance menu. <a href="http://codex.wordpress.org/Function_Reference/add_custom_background">http://codex.wordpress.org/Function_Reference/add_custom_background</a>. Having not tried this &#8211; but I think its limited to a global preference per install &#8211; so of limited use to theme developers.</p>
<p>Anyway nice stuff Jeff Starr at .Net &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-07-25/nice-wordpress-article-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting a page ID in WordPress</title>
		<link>http://www.lazydada.com/2011-04-28/getting-a-page-id-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=getting-a-page-id-in-wordpress</link>
		<comments>http://www.lazydada.com/2011-04-28/getting-a-page-id-in-wordpress/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 19:39:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=918</guid>
		<description><![CDATA[Q. Want to get something in your theme to work with data from a particular page or post &#8211; but don&#8217;t know for sure what that post&#8217;s ID is? A. Try this in your functions.php file: &#8230;then you can then pass a variable about in your theme&#8217;s templates.]]></description>
			<content:encoded><![CDATA[<p>Q. Want to get something in your theme to work with data from a particular page or post &#8211; but don&#8217;t know for sure what that post&#8217;s ID is?</p>
<p>A. Try this in your functions.php file:</p>
<pre class="brush: php; title: ; notranslate">$my_id = $wpdb-&gt;get_var(&quot;SELECT ID FROM $wpdb-&gt;posts WHERE post_name = 'myPost'&quot;);</pre>
<p>&#8230;then you can then <a href="http://www.lazydada.com/2011-04-28/passing-a-variable-about-in-a-wordpress-theme/">pass a variable about</a> in your theme&#8217;s templates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-04-28/getting-a-page-id-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing a variable about in a WordPress theme</title>
		<link>http://www.lazydada.com/2011-04-28/passing-a-variable-about-in-a-wordpress-theme/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=passing-a-variable-about-in-a-wordpress-theme</link>
		<comments>http://www.lazydada.com/2011-04-28/passing-a-variable-about-in-a-wordpress-theme/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 17:58:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=915</guid>
		<description><![CDATA[I&#8217;m used to using php variables set in included  file being used in another included file if all are included in the same document. This doesn&#8217;t work in WordPress theme parts. It&#8217;s easy to overcome though&#8230; you just need to recall the variable first&#8230; somewhere in functions.php Now i can do this somewhere in header.php]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m used to using php variables set in included  file being used in another included file if all are included in the same document. This doesn&#8217;t work in WordPress theme parts. It&#8217;s easy to overcome though&#8230; you just need to recall the variable first&#8230;</p>
<p>somewhere in functions.php</p>
<pre class="brush: php; title: ; notranslate"> $my_var = &quot;xyz&quot; </pre>
<p>Now i can do this somewhere in header.php</p>
<pre class="brush: php; title: ; notranslate">&lt;?php global $myVar ;  ?&gt;
&lt;?php echo $myVar; ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-04-28/passing-a-variable-about-in-a-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple WordPress excerpt lengths</title>
		<link>http://www.lazydada.com/2011-04-28/multiple-wordpress-excerpt-lengths/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=multiple-wordpress-excerpt-lengths</link>
		<comments>http://www.lazydada.com/2011-04-28/multiple-wordpress-excerpt-lengths/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 17:51:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=910</guid>
		<description><![CDATA[Q. Got a theme that needs two different excerpt lengths? A. Found here: set the standard, longer excerpt as normal in the functions.php file and the override locally using this code: &#160;]]></description>
			<content:encoded><![CDATA[<p>Q. Got a theme that needs two different excerpt lengths?</p>
<p>A. Found <a href="http://wordpress.org/support/topic/possible-to-have-2-excerpt-lengths" target="_blank">here</a>: set the standard, longer excerpt as normal in the functions.php file and the override locally using this code:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php echo substr( get_the_excerpt(), 0, strrpos( substr( get_the_excerpt(), 0, 75), ' ' ) ); ?&gt;</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-04-28/multiple-wordpress-excerpt-lengths/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avoid WordPress Trackbacks within your own site</title>
		<link>http://www.lazydada.com/2010-06-15/avoid-wordpress-trackbacks-within-your-own-site/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=avoid-wordpress-trackbacks-within-your-own-site</link>
		<comments>http://www.lazydada.com/2010-06-15/avoid-wordpress-trackbacks-within-your-own-site/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 09:00:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=752</guid>
		<description><![CDATA[So you&#8217;re doing the right thing and crafting internal links within your site to give the thing meaning and usefulness (or SEO)&#8230; but WordPress then adds superfluous trackbacks in the comments of the pages/posts your linking to&#8230; There are plugins to prevent this (of course!) but there&#8217;s no need for them as it&#8217;s very simple [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;re doing the right thing and crafting internal links within your site to give the thing meaning and usefulness (or SEO)&#8230; but WordPress then adds superfluous trackbacks in the comments of the pages/posts your linking to&#8230;</p>
<p>There are plugins to prevent this (of course!) but there&#8217;s no need for them as it&#8217;s very simple thing to prevent; just stick with best-practice and make any internal links root-relative rather than absolute: ie link to <code>/example-post/</code> rather than <code>http://example.com/example-post/</code>.</p>
<p>There&#8217;s an added advantage in that should you ever change your domain &#8211; all your links will stay good.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2010-06-15/avoid-wordpress-trackbacks-within-your-own-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rotating Twitter Tweet feed in WordPress</title>
		<link>http://www.lazydada.com/2010-06-12/rotating-twitter-tweet-feed-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rotating-twitter-tweet-feed-in-wordpress</link>
		<comments>http://www.lazydada.com/2010-06-12/rotating-twitter-tweet-feed-in-wordpress/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 17:04:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=735</guid>
		<description><![CDATA[Again, this is for one my current projects: my mate Phil&#8217;s digital DJ tips site&#8230; OK &#8211; so there&#8217;s loads of plugin&#8217;s out there that do this kind of thing but I&#8217;m not after anything fancy (or bloated), I&#8217;m happy to code this into the theme files with a bit of PHP and well &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Again, this is for one my current projects: my mate Phil&#8217;s <a title="digital DJing advice and reviews" rel="friend met" href="http://www.digitaldjtips.com/">digital DJ tips</a> site&#8230;</p>
<p>OK &#8211; so there&#8217;s loads of plugin&#8217;s out there that do this kind of thing but I&#8217;m not after anything fancy (or bloated), I&#8217;m happy to code this into the theme files with a bit of PHP and well &#8211; it&#8217;s something slightly new to learn &#8230;</p>
<p>Primary requirements:</p>
<ul>
<li>We want this thing to use the <a href="http://simplepie.org/">SimplePie</a> feed parser and cacheing system, as already included with a standard WordPress install. This will copy the latest tweets into WordPress and avoid running-off to bother Twitter every time our WP site gets a visit. This will also make the thing more robust as Twitter does occasionally&#8230; fail.</li>
<li>A raw Twitter feed will include your user name at the beginning of each tweet. This unnecessary when the blog and tweets are from the same person/identity/brand so we&#8217;ll need to remove that.</li>
<li>We need the SimplePie cache to expire fairly regularly &#8211;  not enough to bust Twitter&#8217;s balls with extra requests &#8211; but enough to keep the tweets fresh</li>
<li>We may want to trim the tweets (yes even less than 140 characters!) so they fit on one line without having the set an explicit width or css &#8220;overflow:hidden;&#8221;. [This is a graphic design call here as I like backgrounds fills to match the variable length of text (inline) rather than be fixed-width with trailing whitespace of block level element - makes each tweet look like the unique thing it is.]</li>
<li>Once this is done it goes into a simple carousel to rotate through the last x tweets.</li>
</ul>
<p>The code comes in a couple of pieces:</p>
<h3>The main engine: get the twitter feed &#8211; pack it up and process it.</h3>
<p>I put the following into an include file to keep it all wrapped together for easy access. This code mostly based on the excellent WordPress codex article &#8220;<a href="http://codex.wordpress.org/Function_Reference/fetch_feed">Function Reference/fetch feed</a>&#8220;. The String replace reference came from the classic <a href="http://www.tizag.com/phpT/php-string-str_replace.php">tizag PHP guide</a> and the shorten to the nearest whole word came from somewhere else</p>
<pre class="brush: php; title: ; notranslate">
	&lt;?php
	// Get RSS Feed(s)
	include_once(ABSPATH . WPINC . '/feed.php');

	// Get a SimplePie feed object from the specified feed source. CHANGE THE USER ID BELOW!
	$rss = fetch_feed('http://twitter.com/statuses/user_timeline/126881491.rss');
	if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
	    // Figure out how many total items there are, but limit it to 5.
	    $maxitems = $rss-&gt;get_item_quantity(5);

	    // Build an array of all the items, starting with element 0 (first element).
	    $rss_items = $rss-&gt;get_items(0, $maxitems);
	endif;

	// shorten string function
	function short_str( $str, $len, $cut = true ) {
	    if ( strlen( $str ) &lt;= $len ) return $str;

	    return ( $cut ? substr( $str, 0, $len ) : substr( $str, 0, strrpos( substr( $str, 0, $len ), ' ' ) ) ) . '...';
	}
	?&gt;

&lt;div id=&quot;djt-twitter-feed&quot;&gt;&lt;!-- djt classes and ID to be replaced by something that is useful to you --&gt;
	&lt;ul id=&quot;djt-tweets&quot; class=&quot;jcarousel-skin&quot;&gt;
	    &lt;?php if ($maxitems == 0) echo '&lt;li&gt;No tweets!&lt;/li&gt;';
	    else
	    // Loop through each feed item and display each item as a hyperlink.
	    foreach ( $rss_items as $item ) : ?&gt;
	    &lt;li class=&quot;cfn&quot;&gt;
	        &lt;span&gt;&lt;a href='&lt;?php echo $item-&gt;get_permalink(); //or hardcode link to Twitter homepage ?&gt;'
	        title='&lt;?php echo 'Posted '.$item-&gt;get_date('j F Y | g:i a'); ?&gt;'&gt;
	        &lt;?php //get tweets (but remove twitter ID before displaying)
	        	$djt_twitter_tweet = $item-&gt;get_title();
	        	$djt_twitter_tweet = str_replace(&quot;YourTwitterUsername: &quot;, &quot;&quot;, $djt_twitter_tweet) ;
	        	echo short_str( $djt_twitter_tweet , 140, false) //OK - not actually doing any shortening with this line now ;
	        ?&gt;&lt;/a&gt;&lt;/span&gt;
	    &lt;/li&gt;
	    &lt;?php endforeach; ?&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
<h3>Set the cache expiry in functions.php</h3>
<pre class="brush: php; title: ; notranslate">
// Alter expiry lenght on feeds (set in seconds)
add_filter( 'wp_feed_cache_transient_lifetime', create_function('$a', 'return 480;') );
</pre>
<h3>Finally make it pretty with jCarousel</h3>
<p>The idea was to have one tweet visible at a time &#8211; scrolling/rotating through the list. Grab your copy of <a href="http://sorgalla.com/projects/jcarousel/">jCarousel</a> (it&#8217;s much bigger than <a href="http://www.gmarwaha.com/jquery/jcarousellite/">jCarousel lite</a> but by the time I&#8217;d figured out the <a href="http://www.lazydada.com/2010-06-12/wordpress-jquery-conflict-solved/">trouble with my </a><code><a href="http://www.lazydada.com/2010-06-12/wordpress-jquery-conflict-solved/">wp_head()</a></code> it was time to leave well enough alone. To be revisited when there&#8217;s some time to optimize.) I&#8217;ll not go into the CSS &#8211; that&#8217;s there online.</p>
<pre class="brush: xml; title: ; notranslate">
	&lt;!-- jCarousel --&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;

	function mycarousel_initCallback(carousel) { };

	jQuery(document).ready(function() {
	    jQuery('#djt-tweets').jcarousel({
	        auto: 8,
	        wrap: 'last',
	        vertical: false,
	        scroll: 1,
	        animation: 0,
	        initCallback: mycarousel_initCallback
	    });
	});
	&lt;/script&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2010-06-12/rotating-twitter-tweet-feed-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress jQuery conflict solved</title>
		<link>http://www.lazydada.com/2010-06-12/wordpress-jquery-conflict-solved/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress-jquery-conflict-solved</link>
		<comments>http://www.lazydada.com/2010-06-12/wordpress-jquery-conflict-solved/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 00:01:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=733</guid>
		<description><![CDATA[After several hours of thinking I&#8217;m being a idiot (happens occasionally) I discovered that sometimes you&#8217;ll need to call before any jQuery scripts (or concatenated scripts in my case). It&#8217;s been hours and I couldn&#8217;t figure out why none of the Carousel scripts I was trying today wanted to work &#8211; while all other scripts [...]]]></description>
			<content:encoded><![CDATA[<p>After several hours of thinking I&#8217;m being a idiot (happens occasionally) I discovered that sometimes you&#8217;ll need to call</p>
<pre class="brush: php; title: ; notranslate">&lt;?php wp_head(); ?&gt;</pre>
<p>before any jQuery scripts (or concatenated scripts in my case).</p>
<p>It&#8217;s been hours and I couldn&#8217;t figure out why none of the Carousel scripts I was trying today wanted to work &#8211; while all other scripts and plugins carried on just fine.</p>
<p>And yes &#8211; I am already trying to prevent jQuery conflicts with</p>
<pre class="brush: php; title: ; notranslate">&lt;?php wp_enqueue_script(&quot;jquery&quot;); ?&gt;</pre>
<p>So if your carousel (or other) scripts don&#8217;t want to work &#8211; try shaking up your <code>head</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2010-06-12/wordpress-jquery-conflict-solved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress loop with x big posts in one column then a grid of y smaller posts in z columns</title>
		<link>http://www.lazydada.com/2010-06-10/fancy-wordpress-loop-with-main-posts-and-then-grid-of-post-in-rows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fancy-wordpress-loop-with-main-posts-and-then-grid-of-post-in-rows</link>
		<comments>http://www.lazydada.com/2010-06-10/fancy-wordpress-loop-with-main-posts-and-then-grid-of-post-in-rows/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 18:14:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=718</guid>
		<description><![CDATA[Here&#8217;s how I managed to get this loop to work for the custom WordPress theme I whacked off for my friend and erstwhile colleague Phil Morse AKA Digital DJ Tips The challenge I set myself was to get the loop to display posts in two formats: first a certain number of posts with large excerpts and [...]]]></description>
			<content:encoded><![CDATA[<h4>Here&#8217;s how I managed to get this loop to work for the custom WordPress theme I whacked off for my friend and erstwhile colleague Phil Morse AKA <a title="Digital DJ Tips, tricks and reviews" href="http://www.digitaldjtips.com/" target="_blank">Digital DJ Tips</a></h4>
<p>The challenge I set myself was to get the loop to display posts in two formats: first a certain number of posts with large excerpts and any images via <code>the_content</code> then a grid of 3 rows of mini-posts showing just the title… it may not sound tricky but the devil is in the detail: stepping in and out of the loop to open and close container divs is not widely documented (well not that I could find)&#8230;</p>
<p>Couple of catches</p>
<ul>
<li>using multiple loop solutions causes the pagination to fail: link to older posts would reload the same content. To get proper pagination you need to stick with one loop.</li>
<li>I needed to inject some HTML in and around the mini posts to keep formatting and layout controllable:
<ul>
<li>need to add a class of &#8220;last&#8221; on the last item in a row to make use of the full width available with margin right on all except the last element of the row</li>
<li><div id="attachment_726" class="wp-caption alignright" style="width: 130px"><a href="http://www.lazydada.com/wp-content/uploads/2010/06/float-stack-horror1.jpg"><img class="size-thumbnail wp-image-726" title="float-stack-horror" src="http://www.lazydada.com/wp-content/uploads/2010/06/float-stack-horror1-150x150.jpg" alt="" width="120" height="120" /></a><p class="wp-caption-text">beware the dreaded...</p></div>each row of x mini-posts had to be wrapped in a div as these mini-posts are of unequal height (a design decision). With uneven heights floating them all within a single div causes the dreaded float-stack-horror.</li>
</ul>
</li>
<li>As we&#8217;re injecting extra HTML markup every x items we also need to be able to close this markup prematurely if we run out of posts before the row is finished. Therefore we need to know the total number of posts in the loop so this thing can close itself early if need be.</li>
</ul>
<p>In the end I also decided that I wanted the logic to be easily adaptable to allow changes to the number of full excerpt posts and the number of columns in the following rows. Thats easily changed with the variable set at the outset here and by varying the denominator in the integer test bit (simplerer than it sounds).</p>
<h4>Cut-n-paste to the chase already&#8230;</h4>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;"> </span></p>
<pre class="brush: php; title: ; notranslate">&lt;/span&gt;
&lt;pre&gt;&lt;?php

get_header(); ?&gt;

	&lt;div id=&quot;content&quot;&gt;

	&lt;?php if (have_posts()) : ?&gt;
	&lt;?php
		/* Custom loop to show n main posts (title + excerpt) then
		   finish with remainder as small posts (just title) in markup that allows
		   columns of unequal mini-posts in rows.

		   Here one main post then subsequent mini-posts in rows of 3.
		   Total number per page defined in WP options

		*/
 		$count = 0; //start the counter
		$main_posts = 1; //set the number of main posts
	?&gt;

	&lt;?php // find out how many posts so we can close this thing properly at the last post
	$totalposts = sizeof($posts); ?&gt;

	&lt;?php while (have_posts()) : the_post(); ?&gt;
	&lt;?php $count++; //increment counter by 1 ?&gt;
	&lt;?php $small_posts_count = ($count - $main_posts) ; // calculate the number of small posts ?&gt;
	  &lt;?php if ($count &lt; ($main_posts + 1)) : // if within the range of main post set above then...  ?&gt;
				&lt;div &lt;?php post_class('sheet') ?&gt; id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;
					&lt;h2&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to &lt;?php the_title_attribute(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
					&lt;div class=&quot;entry&quot;&gt;
						&lt;?php the_content('Read more') ; ?&gt;
					&lt;/div&gt;
				&lt;/div&gt;
		&lt;?php else : // if loop is at small_posts start a wrapper div.loop2 for next row of posts ?&gt;
			&lt;?php // if (count-1)/3 is an integer then it's first in the row: open the wrapper
				if (($small_posts_count - 1) % 3 == 0 ) { echo '&lt;div class=&quot;loop2 clearfix&quot;&gt;';} ?&gt;
				&lt;div class=&quot;sheet&lt;?php if ((isset($small_posts_count)) &amp;&amp; ($small_posts_count % 3 == 0 )) { echo ' last';} // same logic to add class of last to last item in row of three ?&gt;&quot; id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;
					&lt;h4&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to &lt;?php the_title_attribute(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h4&gt;
				&lt;/div&gt;
			&lt;?php //close the row if multiple of three (using same logic as above) or if it's the last post
				if (($count == $totalposts) || ($small_posts_count % 3 == 0 )) { echo '&lt;/div&gt;&lt;!-- .loop2 --&gt;';} // if is multiple of three ?&gt;

	  &lt;?php endif; ?&gt;

		&lt;?php endwhile; ?&gt;

		&lt;?php if (!is_page()) { // get older and/or newer posts links (not for single posts) ?&gt;
		&lt;?php include( TEMPLATEPATH . '/tpl.nav.posts.php' );  ?&gt;
		&lt;?php ; } ?&gt;

		&lt;?php else : ?&gt;
		&lt;?php include( TEMPLATEPATH . '/tpl.search.404.php' ); // get 404 error message ?&gt;
	&lt;?php endif; ?&gt;

	&lt;/div&gt;

&lt;?php get_sidebar(); ?&gt;

&lt;?php get_footer(); ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2010-06-10/fancy-wordpress-loop-with-main-posts-and-then-grid-of-post-in-rows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Long/short headings (or title tags) using WordPress Custom Fields</title>
		<link>http://www.lazydada.com/2010-05-19/longshort-headings-or-title-tags-using-wordpress-custom-fields/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=longshort-headings-or-title-tags-using-wordpress-custom-fields</link>
		<comments>http://www.lazydada.com/2010-05-19/longshort-headings-or-title-tags-using-wordpress-custom-fields/#comments</comments>
		<pubDate>Wed, 19 May 2010 11:24:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=698</guid>
		<description><![CDATA[[ This post is now largely if not entirely redundant now thanks to WordPress 3 menu options ] Problem: WP titles are too long to fit in your navigation. Solution: Make the title short enough to fit in the navigation and then add a Custom Field into your post (in the example bellow it is [...]]]></description>
			<content:encoded><![CDATA[<p>[ This post is now largely if not entirely redundant now thanks to WordPress 3 menu options ]</p>
<h4>Problem: WP titles are too long to fit in your navigation.</h4>
<h4>Solution:</h4>
<p>Make the title short enough to fit in the navigation and then add a Custom Field into your post (in the example bellow it is set as &#8220;heading&#8221;) then edit your template file to render the longer version (&#8220;heading&#8221;) on the page.</p>
<h4>Example:</h4>
<p>In the Loop of  your template swap out</p>
<pre class="phpcode">&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
&lt;?php the_content(); ?&gt;</pre>
<p>for:</p>
<pre class="phpcode">&lt;h1&gt;&lt;?php// If has a custom field of heading ; then use that:
$customField = get_post_custom_values("heading");
if (isset($customField[0])) {
echo $customField[0];
} else {
the_title();
} ; ?&gt;&lt;/h1&gt;
&lt;?php the_content(); ?&gt;</pre>
<p>Hat-tip: <a href="http://www.smashingmagazine.com/2009/05/13/10-custom-fields-hacks-for-wordpress/" target="_blank">Smashing Magazine</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2010-05-19/longshort-headings-or-title-tags-using-wordpress-custom-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
