<?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>AEXT.NET MAGAZINE &#187; the_content</title>
	<atom:link href="http://aext.net/tag/the_content/feed/" rel="self" type="application/rss+xml" />
	<link>http://aext.net</link>
	<description>How to Create a Website</description>
	<lastBuildDate>Wed, 30 May 2012 05:03:57 +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>WordPress Hack: Anything Can Be Added Anywhere In The Post Content</title>
		<link>http://aext.net/2009/10/wordpress-hack-anything-can-be-added-anywhere-in-the-post-content/</link>
		<comments>http://aext.net/2009/10/wordpress-hack-anything-can-be-added-anywhere-in-the-post-content/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 06:07:05 +0000</pubDate>
		<dc:creator>Lief</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[the_content]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress Theme]]></category>

		<guid isPermaLink="false">http://aext.net/?p=1182</guid>
		<description><![CDATA[<p><a href="http://aext.net/theme/platinoom" title="Platinoom - Premium WordPress Themes"><img src="http://aext.net/wp-content/uploads/2011/04/platinoom_wordpress_theme.png" alt="ThemeKiss" /></a></p><p style="float: right;"><a href="http://api.tweetmeme.com/share?url=http://aext.net/2009/10/wordpress-hack-anything-can-be-added-anywhere-in-the-post-content/&service=su.pr&service_api=b57727e991c454bd2b2c62ff71462c79"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http://aext.net/2009/10/wordpress-hack-anything-can-be-added-anywhere-in-the-post-content/" height="61" width="51" /></a></p>Some of wordpress plugins automatically add their display below your post content which is such as: YARPP (Related Posts) or Sociable .... They added their displays into your post content, but sometime, you want to add your own code before them. This article will tell you how to add anything to your wordpress theme just right before others plugin. <a href="http://aext.net/2009/10/wordpress-hack-anything-can-be-added-anywhere-in-the-post-content/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://aext.net/theme/platinoom" title="Platinoom - Premium WordPress Themes"><img src="http://aext.net/wp-content/uploads/2011/04/platinoom_wordpress_theme.png" alt="ThemeKiss" /></a></p><p style="float: right;"><a href="http://api.tweetmeme.com/share?url=http://aext.net/2009/10/wordpress-hack-anything-can-be-added-anywhere-in-the-post-content/&service=su.pr&service_api=b57727e991c454bd2b2c62ff71462c79"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http://aext.net/2009/10/wordpress-hack-anything-can-be-added-anywhere-in-the-post-content/" height="61" width="51" /></a></p><p>Some of wordpress plugins automatically add their display below your post content which is such as: YARPP (Related Posts) or Sociable &#8230;. They added their displays into your post content, but sometime, you want to add your own code before them, even between the introduction and the main content. This article will tell you how to add anything to your wordpress theme just right before others plugin do.</p>
<p><span id="more-1182"></span></p>
<p>This is the first tutorial that I don&#8217;t offer the download link. Just follow these simple steps and you&#8217;ll get the nice results.</p>
<h3>Hack your theme functions.php file</h3>
<hr />
<p>The only thing you want to do is just hack your theme <em>functions.php</em>file.</p>
<p>Open this file.</p>
<p>In this article, I will add the author bio box into wordpress theme before the Related Posts displays. Write a function that return the author bio box, you can write anywhere, but at the end of your <em>functions.php</em> is avoid messing up your file:</p>
<pre class="php"><span style="color: #881350;">function</span> <span style="color: #003369;">get_author_bio </span>(<span style="color: #825900;">$content</span>=<span style="color: #eb7300;">''</span>){<span style="color: #881350;">Â </span><span style="color: #825900;">Â </span>

Â Â Â Â <span style="color: #881350;">if</span>(!<span style="color: #003369;">in_category</span>(<span style="color: #eb7300;">"Community News"</span>)) {
Â Â Â Â <span style="color: #825900;">$post_author_name</span>=<span style="color: #003369;">get_the_author_meta</span>(<span style="color: #eb7300;">"display_name"</span>);
Â Â Â Â <span style="color: #825900;">$post_author_description</span>=<span style="color: #003369;">get_the_author_meta</span>(<span style="color: #eb7300;">"description"</span>); Â Â Â Â Â 

Â Â Â Â <span style="color: #825900;">$html</span>=<span style="color: #eb7300;">"&lt;div class='clearfix' id='about_author'&gt;\n"</span>;
Â Â Â Â <span style="color: #825900;">$html</span>.=<span style="color: #eb7300;">"&lt;img width='80' height='80' class='avatar' src='http://www.gravatar.com/avatar.php?gravatar_id="</span>.<span style="color: #661aa9;">md5</span>(<span style="color: #003369;">get_the_author_email</span>()). <span style="color: #eb7300;">"&amp;default="</span>.<span style="color: #661aa9;">urlencode</span>(<span style="color: #825900;">$GLOBALS</span>[<span style="color: #eb7300;">'defaultgravatar'</span>]).<span style="color: #eb7300;">"&amp;size=80&amp;r=PG' alt='PG'/&gt;\n"</span>;

Â Â Â Â <span style="color: #825900;">$html</span>.=<span style="color: #eb7300;">"&lt;div class='author_text'&gt;\n"</span>;
Â Â Â Â <span style="color: #825900;">$html</span>.=<span style="color: #eb7300;">"&lt;h4&gt;Author: &lt;span&gt;"</span>.<span style="color: #825900;">$post_author_name</span>.<span style="color: #eb7300;">"&lt;/span&gt;&lt;/h4&gt;\n"</span>;
Â Â Â Â <span style="color: #825900;">$html</span>.= <span style="color: #825900;">$post_author_description</span>.<span style="color: #eb7300;">"\n"</span>;
Â Â Â Â <span style="color: #825900;">$html</span>.=<span style="color: #eb7300;">"&lt;/div&gt;\n"</span>;
Â Â Â Â <span style="color: #825900;">$html</span>.=<span style="color: #eb7300;">"&lt;div class='clear'&gt;&lt;/div&gt;\n"</span>;
Â Â Â Â <span style="color: #825900;">$html</span>.=<span style="color: #eb7300;">"&lt;/div&gt;"</span>;
Â Â Â Â <span style="color: #825900;">$content</span> .= <span style="color: #825900;">$html</span>;

Â Â Â Â }

Â Â Â Â <span style="color: #881350;">return</span> <span style="color: #825900;">$content</span>;

}</pre>
<p>In WordPress 2.8 and above, <em>the_author_description();</em> has been deprecated and replaced with another function: <em>the_author_meta(&#8216;description&#8217;);</em>. However, you have to use <em>get_the_author_meta()</em> if you need to return (not display) the information. Take a look at this function&#8217;s information at <a href="http://codex.wordpress.org/Template_Tags/the_author_meta">WordPress Codex</a>.</p>
<p>In this function, I set the condition that the bio box will not display if this post is in <strong>Community News</strong> category. I&#8217;m using the same as above. This function is not return the bio box, it joins the post content and bio box content into one.</p>
<p>Next, you need to hook this function to <em>the_content</em> with code:</p>
<pre class="html"><span style="color: #003369;">add_filter</span>(<span style="color: #eb7300;">'the_content'</span>, <span style="color: #eb7300;">'get_author_bio'</span>);</pre>
<p>For the example, before you use this hack, your bio box will display after the Related Posts, likes this:</p>
<div class="bigimage"><img class="aligncenter size-full wp-image-1193" title="wordpress hack bio box" src="http://aext.net/wp-contents/uploads/2009/10/wordpress-hack-bio-box.jpg" alt="wordpress hack bio box" width="500" height="335" /></div>
<p>But after you did some hacks in <em>functions.php</em> file, you will get a result likes mine at the end of this post.</p>
<p>To display something at the begin, easy as adding it normally into your post theme file: <em>single.php</em></p>
<p>Sometime, you want to display your ads right below your post&#8217;s introduction. We will need to split the content into two parts, then insert ads code at the middle. Let&#8217;s write a function likes this:</p>
<pre class="php"><span style="color: #881350;">function</span> <span style="color: #003369;">put_middle_content</span>(<span style="color: #825900;">$content</span>=<span style="color: #eb7300;">''</span>) {

Â Â Â Â <span style="color: #881350;">if</span>( <span style="color: #661aa9;">preg_match</span>(<span style="color: #eb7300;">'/&lt;span id="(.*?)?"&gt;&lt;\/span&gt;/'</span>, <span style="color: #825900;">$content</span>, <span style="color: #825900;">$matches</span>) ) {

Â Â Â Â Â Â Â Â <span style="color: #825900;">$content</span> = <span style="color: #661aa9;">explode</span>(<span style="color: #825900;">$matches</span>[<span style="color: #0000ff;">0</span>], <span style="color: #825900;">$content</span>, <span style="color: #0000ff;">2</span>);

Â Â Â Â Â Â Â Â <span style="color: #825900;">$content</span> = <span style="color: #825900;">$content</span>[<span style="color: #0000ff;">0</span>] . <span style="color: #825900;">$matches</span>[<span style="color: #0000ff;">0</span>] . <span style="color: #eb7300;">'[YOUR ADS ARE HERE]'</span> . <span style="color: #825900;">$content</span>[<span style="color: #0000ff;">1</span>];
Â Â Â Â }

Â Â Â Â <span style="color: #881350;">return</span> <span style="color: #825900;">$content</span>;

}</pre>
<p>If your post has <em>More</em> tag, this function will split the content into 2 parts with delimiter is the <em>More</em> tag. Then, It will combine the content array again with the adding between 2 array strings.</p>
<p>Adding the code below to complete:</p>
<pre class="html"><span style="color: #003369;">add_filter</span>(<span style="color: #eb7300;">'the_content'</span>, <span style="color: #eb7300;">'put_middle_content'</span>);</pre>
<h3>That&#8217;s all</h3>
<hr />
<p>Yup, that&#8217;s all. Now, you can add anything you want to anywhere, such as: top, middle, and right after the post content that you could not do with the template display file. Your adding&#8217;s priority will be always the first.</p>
<div class="txtad-cont"></div>
]]></content:encoded>
			<wfw:commentRss>http://aext.net/2009/10/wordpress-hack-anything-can-be-added-anywhere-in-the-post-content/feed/</wfw:commentRss>
		<slash:comments>80</slash:comments>
		</item>
	</channel>
</rss>

