<?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>Digging into WordPress &#187; content</title>
	<atom:link href="http://digwp.com/tag/content/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Fri, 18 May 2012 18:21:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Shortcode for Includes</title>
		<link>http://digwp.com/2010/06/shortcode-for-includes/</link>
		<comments>http://digwp.com/2010/06/shortcode-for-includes/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 09:08:19 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[shortcode]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2365</guid>
		<description><![CDATA[One thing that WordPress doesn&#8217;t have the ability to do &#8220;out-of-the-box&#8221; is do includes, in the sense of including the content of one post into the content of another post directly in the post editor. For the umpteenth time around here, shortcodes to the rescue! This issue came up while my co-worker Tim at Wufoo [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that WordPress doesn&#8217;t have the ability to do &#8220;out-of-the-box&#8221; is do <em>includes</em>, in the sense of including the content of one post into the content of another post directly in the post editor. For the <a href="http://digwp.com/tag/shortcode/">umpteenth time</a> around here, shortcodes to the rescue! </p>
<p><span id="more-2365"></span></p>
<p>This issue came up while my co-worker Tim at <a href="http://wufoo.com">Wufoo</a> was documenting parts of the latest <a href="http://wufoo.com/docs/api/v3/">Wufoo API</a>. Some of the API pages have areas on them that are exactly the same as other pages, for example, a chunk of navigation that links to other pages of documentation.</p>
<p>One possible way to deal with this is to make a special template just for these pages and include that chunk inside that template. This solution edges on the issue of template-bloat which I&#8217;ve been thinking a lot about lately. Creating a new template every time you need one little change is solving the problem with a sledgehammer rather than a scalpel. </p>
<p>The ideal solution is just to make a shortcode. You pass the ID of the post (in our case, page) that you want to include and the shortcode is replaced with that content. This is the usage, where XXXX would be the ID of the post:</p>
<pre><code>[digwp_include postidparam=XXXX]</code></pre>
<p>To make it work, we&#8217;ll add a fairly simple function to the functions.php file in our theme. The function will take the parameter, run a query for it, and return back the content if it finds any:</p>
<pre><code>function digwp_includeContentShortcode($atts) {
  
  $thepostid = intval($atts[postidparam]);
  $output = '';

  query_posts("p=$thepostid&amp;post_type=page");
  if (have_posts()) : while (have_posts()) : the_post();
    $output .= get_the_content($post-&gt;ID);
  endwhile; else:
    // failed, output nothing
  endif;
  wp_reset_query();

  return $output;

}

// USAGE
// In the post content, you can use [digwp_include postidparam="1234"]
// "1234" would be the WordPress ID of the Page you are trying to include

add_shortcode("digwp_include", "digwp_includeContentShortcode");</code></pre>
<p>Now you can publish small modules of content, and include them on any Post/Page that needs them! I&#8217;d probably create a Page on your site called like &#8220;Includes&#8221; or &#8220;Modules&#8221; and post them as Pages with that as the Parent Page. That way you don&#8217;t clutter up the root and they all stay organized together. </p>
<p>Check out this graphic (click for full size), which hopefully will drive home the idea:</p>
<p><a href="http://digwp.com/wp-content/blog-images/20100621-qgt1km86je73ci7ikwjpp3bexw.png"><img src="http://digwp.com/wp-content/blog-images/_20100621-qgt1km86je73ci7ikwjpp3bexw.png" width="570" height="442" alt="" title=""  /></a></p>
<p>Random notes: </p>
<ul>
<li>This is similar to the <a href="http://digwp.com/2010/01/custom-query-shortcode/">custom loop shortcode</a> I previously published.</li>
<li>This may be good territory for a plugin rather than functions.php code as I have done.</li>
<li>Notice the function is <a href="http://www.andrewnacin.com/2010/05/11/in-wordpress-prefix-everything/">properly prefixed</a>.</li>
</ul>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/06/shortcode-for-includes/">Permalink</a> | <a href="http://digwp.com/2010/06/shortcode-for-includes/#comments">28 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/06/shortcode-for-includes/&title=Shortcode for Includes">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/content/" rel="tag">content</a>, <a href="http://digwp.com/tag/include/" rel="tag">include</a>, <a href="http://digwp.com/tag/shortcode/" rel="tag">shortcode</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/06/shortcode-for-includes/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Plugin Spotlight: Postalicious</title>
		<link>http://digwp.com/2009/08/plugin-spotlight-postalicious/</link>
		<comments>http://digwp.com/2009/08/plugin-spotlight-postalicious/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 14:24:30 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=554</guid>
		<description><![CDATA[The social bookmarking service Delicious has always been friendly with WordPress. In fact, right from the settings of your Delicious account you can set up a blog posting &#8220;job&#8221; which will literally post your links directly to your blog with no intervention on your part (instructions on that here). Using this system to post directly [...]]]></description>
			<content:encoded><![CDATA[<p>The social bookmarking service <a href="http://delicious.com/">Delicious</a> has always been friendly with WordPress. In fact, right from the settings of your Delicious account you can set up a blog posting &#8220;job&#8221; which will literally post your links directly to your blog with no intervention on your part (<a href="http://theory.isthereason.com/?p=499">instructions on that here</a>).</p>
<p>Using this system to post directly from Delicious is kind of neat, but it lacks severely in control. The Post titles aren&#8217;t as customizable as you might like, it&#8217;s auto-post or nothing, it posts to the default category with the default author, and posts all links on a daily basis. This is where <a href="http://neop.gbtopia.com/?p=108">Postalicious</a> comes in.</p>
<p><span id="more-554"></span></p>
<p>I really like the idea of blogging through social bookmarks, specifically Delicious. They have a <a href="https://addons.mozilla.org/en-US/firefox/addon/3615">Firefox plugin</a> that makes saving bookmarks with notes and tags extremely easy. I also have a little bookmarklet called <a href="http://github.com/garrettmurray/quickbite/tree/master">Quickbite</a> for when I literally just want to press a button and save the link without being troubled with writing anything. However, I wasn&#8217;t thrilled with automatic Delicious posting that is offered. </p>
<p>My friend <a href="http://fresharrival.com/">Richard</a> was in just this position, and was asking me if I knew of any plugins that did good Delicious/WordPress integration. We both went searching around and he came up with <a href="http://neop.gbtopia.com/?p=108">Postalicious</a>.  I&#8217;ve now been using it for a few weeks on my <a href="http://chriscoyier.net/">personal blog</a> and I really like it.</p>
<p>Here are some features:</p>
<ul>
<li>Integration with major services like Delicious, Google Reader, and Reddit</li>
<li>Post to specific categories, by specific authors</li>
<li>Save Posts as drafts</li>
<li>Grab new links at timed intervals and publish at timed intervals</li>
<li>Full HTML control over structure of Post, including Title</li>
</ul>
<p>Screenshot of settings:</p>
<p><img src="http://digwp.com/wp-content/blog-images/posalicious-settings.png" width="590" height="647" alt="" title="" /></p>
<p>My favorite feature is the draft saving. I like to fine-tune, so I&#8217;m kind of opposed to any automatic system publishing things for me. As you can see, new links are put into new drafts, saved, and ready for me to edit and publish on my own:</p>
<p><img src="http://digwp.com/wp-content/blog-images/drafts-postalicious.png" width="590" height="241" alt="" title="" /></p>
<p>Cheers to Pablo GÃ³mez Basanta and his great work on <a href="http://neop.gbtopia.com/?p=108">Postalicious</a>!</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/08/plugin-spotlight-postalicious/">Permalink</a> | <a href="http://digwp.com/2009/08/plugin-spotlight-postalicious/#comments">5 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/08/plugin-spotlight-postalicious/&title=Plugin Spotlight: Postalicious">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/content/" rel="tag">content</a>, <a href="http://digwp.com/tag/links/" rel="tag">Links</a>, <a href="http://digwp.com/tag/plugin/" rel="tag">plugin</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/08/plugin-spotlight-postalicious/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Putting the_content() into a PHP Variable</title>
		<link>http://digwp.com/2009/07/putting-the_content-into-a-php-variable/</link>
		<comments>http://digwp.com/2009/07/putting-the_content-into-a-php-variable/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 13:41:38 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=189</guid>
		<description><![CDATA[There are probably a couple ways to do this, but here is a really easy one: ob_start(); the_content(); $content = ob_get_clean(); This is called &#8220;output buffering&#8221; where the output is redirected from being directly sent out to being written to a buffer. Why? In case you need to do any manipulation or calculation of the [...]]]></description>
			<content:encoded><![CDATA[<p>There are probably a couple ways to do this, but here is a really easy one:</p>
<pre><code>ob_start();
the_content();
$content = ob_get_clean();</code></pre>
<p><span id="more-189"></span><br />
This is called  &#8220;output buffering&#8221; where the output is redirected from being directly sent out to being written to a buffer. </p>
<h3>Why?</h3>
<p>In case you need to do any manipulation or calculation of the content before outputting it. Admittedly, it&#8217;s probably not a very common need. </p>
<p>For example, on a recent redesign of one of my sites <a href="http://quotesondesign.com">Quotes on Design</a>, I wanted to count the number of words in a quote so I could set the font-size based on that. </p>
<pre><code>$numWords =  sizeof(explode(" ", $content));</code></pre>
<h3>Warning</h3>
<p>There are things you could do with this that are probably best done in other ways. For example, maybe you want to remove the paragraph tags that WordPress likes to append to content automatically for you. You&#8217;d be better off removing that filter (from your functions.php file) than messing with this.</p>
<pre><code>remove_filter ('the_content','wpautop');</code></pre>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/07/putting-the_content-into-a-php-variable/">Permalink</a> | <a href="http://digwp.com/2009/07/putting-the_content-into-a-php-variable/#comments">17 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/07/putting-the_content-into-a-php-variable/&title=Putting the_content() into a PHP Variable">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/content/" rel="tag">content</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/07/putting-the_content-into-a-php-variable/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

