<?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>MasterMind Blogger &#187; wordpress custom hack</title>
	<atom:link href="http://www.mastermindblogger.com/tag/wordpress-custom-hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mastermindblogger.com</link>
	<description>Learn the Skills To Build A Profitable Blog</description>
	<lastBuildDate>Wed, 08 Feb 2012 11:09:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Top 8 WordPress Tricks And Hacks</title>
		<link>http://www.mastermindblogger.com/2009/top-8-wordpress-tricks-and-hacks/</link>
		<comments>http://www.mastermindblogger.com/2009/top-8-wordpress-tricks-and-hacks/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 20:08:01 +0000</pubDate>
		<dc:creator>Salman Ahsan</dc:creator>
				<category><![CDATA[WordPress Tricks & Hacks]]></category>
		<category><![CDATA[author bio hack]]></category>
		<category><![CDATA[Top 8 WordPress Tricks And Hacks]]></category>
		<category><![CDATA[wordpress adsense hack]]></category>
		<category><![CDATA[wordpress custom hack]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[WordPress Tricks And Hacks]]></category>

		<guid isPermaLink="false">http://www.mastermindblogger.com/?p=345</guid>
		<description><![CDATA[Imagine if you knew how to code wordpress themes and designs then you wouldn’t have to spend massive amount of money on purchasing it. Usually, I work on the themes on most of my blogs. I enjoy tweaking all the time because it is very essential for your blog. I am sure most of you [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Imagine if you knew how to code wordpress themes and designs then you wouldn’t have to spend massive amount of money on purchasing it. Usually, I work on the themes on most of my blogs. I enjoy tweaking all the time because it is very essential for your blog.</p>
<p>I am sure most of you would love to discover some cool wordpress hacks and I hope you enjoy this article. If you are not a pro then I would suggest that you try these on a new wordpress installation.</p>
<div id="attachment_296" class="wp-caption aligncenter" style="width: 500px;  border: 1px solid #dddddd; background-color: #f3f3f3; padding-top: 4px; margin: 10px; text-align:center; display: block; margin-right: auto; margin-left: auto;">
	<a href="http://www.mastermindblogger.com/wp-content/uploads/2009/12/090917_wordpress-hacks-tricks.jpg"><img class="size-full wp-image-296" title="090917_wordpress-hacks-tricks" src="http://www.mastermindblogger.com/wp-content/uploads/2009/12/090917_wordpress-hacks-tricks.jpg" alt="" width="500" height="400" /></a>
	<p style=' padding: 0 4px 5px; margin: 0;'  class="wp-caption-text">Wordpress Tricks and Hacks </p>
</div>
<h2>How to display Adsense when you Only want to</h2>
<p>To use this trick, you need a self hosted wordpress and an adsense account of course.<br />
Insert the following code into your function.php file. All or majority of the themes come with a function.php file.</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">
<p class="MsoNormal">function showads() {</p>
<p class="MsoNormal">
<p class="MsoNormal"><span style="mso-spacerun: yes;"> </span>return &#8216;&lt;script type=&#8221;text/javascript&#8221;&gt;&lt;!&#8211;</p>
<p class="MsoNormal"><span style="mso-spacerun: yes;"> </span>google_ad_client = &#8220;pub-xxxxxxxxxxxxxxx&#8221;;</p>
<p class="MsoNormal"><span style="mso-spacerun: yes;"> </span>google_ad_slot = &#8220;4668915978&#8243;;</p>
<p class="MsoNormal"><span style="mso-spacerun: yes;"> </span>google_ad_width = 468;</p>
<p class="MsoNormal"><span style="mso-spacerun: yes;"> </span>google_ad_height = 60;</p>
<p class="MsoNormal"><span style="mso-spacerun: yes;"> </span>//&#8211;&gt;</p>
<p class="MsoNormal"><span style="mso-spacerun: yes;"> </span>&lt;/script&gt;</p>
<p class="MsoNormal"><span style="mso-spacerun: yes;"> </span>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;http://pagead2.googlesyndication.com/pagead/show_ads.js&#8221;&gt;</p>
<p class="MsoNormal"><span style="mso-spacerun: yes;"> </span>&lt;/script&gt;&#8217;;</p>
<p class="MsoNormal">}</p>
</td>
</tr>
</tbody>
</table>
<p>Once you are done, you will be able to insert adsense whenever and wherever you want it in your post. To do that, simply paste the following code in your post (make sure you are in the HTML mode)</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">[adsense]
</td>
</tr>
</tbody>
</table>
<h2>How to Show Parent Page Title regardless of what Subpage you are on</h2>
<p>Now this is only for the people who are using wordpress as their content management system. Simply  paste the code anywhere on your theme files and it will display the parent page title.</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">
<div id="_mcePaste">&lt;?php</div>
<div id="_mcePaste">if($post-&gt;post_parent) {</div>
<div id="_mcePaste">$parent_title = get_the_title($post-&gt;post_parent);</div>
<div id="_mcePaste">echo $parent_title;</div>
<div id="_mcePaste">} else {</div>
<div id="_mcePaste">wp_title(&#8221;);</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">?&gt;</div>
<p>&lt;?phpif($post-&gt;post_parent) {    $parent_title = get_the_title($post-&gt;post_parent);    echo $parent_title;} else {    wp_title(&#8221;);}?&gt;</td>
</tr>
</tbody>
</table>
<h2>How to Automatically insert Author Bio on each post</h2>
<p>This is best used on a blog owned by multiple authors. If you write a post, you would definitely want to take the credit for it and thus display your bio on the post.  If you have guest bloggers then this is a great method to give them credit for their contribution</p>
<p>Simply insert the following code into your functions.php file and it is good to go. Author bio will be automatically displayed after each post.</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">function get_author_bio ($content=&#8221;){<br />
global $post;<br />
$post_author_name=get_the_author_meta(&#8220;display_name&#8221;);<br />
$post_author_description=get_the_author_meta(&#8220;description&#8221;);<br />
$html=&#8221;&lt;div class=&#8217;clearfix&#8217; id=&#8217;about_author&#8217;&gt;\n&#8221;;<br />
$html.=&#8221;&lt;img width=&#8217;80&#8242; height=&#8217;80&#8242; class=&#8217;avatar&#8217; src=&#8217;http://www.gravatar.com/avatar.php?gravatar_id=&#8221;.md5(get_the_author_email()). &#8220;&amp;default=&#8221;.urlencode($GLOBALS['defaultgravatar']).&#8221;&amp;size=80&amp;r=PG&#8217; alt=&#8217;PG&#8217;/&gt;\n&#8221;;</p>
<p>$html.=&#8221;&lt;div class=&#8217;author_text&#8217;&gt;\n&#8221;;<br />
$html.=&#8221;&lt;h4&gt;Author: &lt;span&gt;&#8221;.$post_author_name.&#8221;&lt;/span&gt;&lt;/h4&gt;\n&#8221;;<br />
$html.= $post_author_description.&#8221;\n&#8221;;<br />
$html.=&#8221;&lt;/div&gt;\n&#8221;;<br />
$html.=&#8221;&lt;div class=&#8217;clear&#8217;&gt;&lt;/div&gt;\n&#8221;;<br />
$content .= $html;</p>
<p>}</p>
<div id="about_author" class="clearfix">
return $content;<br />
}<br />
add_filter(&#8216;the_content&#8217;, &#8216;get_author_bio&#8217;);</p>
</div>
</td>
</tr>
</tbody>
</table>
<h2>Speed up Your Blog’s Loading Speed</h2>
<p>There are so many web hosting that it is difficult to find out which one is best for blogging. Your host might be slow and it can annoy your readers. Do you know that you can lose tons of readers if your blog lags or loads really slow.</p>
<p>You need zlib php extension enabled by your hosting provider. Once that is taken care of, simply place the following code in your header (above the DOCTYPE). Save the file and enjoy the speed.</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">
<div id="_mcePaste">
<div id="_mcePaste">&lt;?php</div>
<div>ini_set(&#8216;zlib.output_compression&#8217;, &#8216;On&#8217;);</div>
<div id="_mcePaste">ini_set(&#8216;zlib.output_compression_level&#8217;, &#8217;1&#8242;);</div>
<div id="_mcePaste">?&gt;</div>
</div>
</td>
</tr>
</tbody>
</table>
<h2>How to Display registered users comment count on your Blog</h2>
<p>If your blog has a lot of registered users, then you may want to display the number of comments posted by them. Paste the code below wherever you want to display the count.</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">&lt;?php</p>
<p>global $wpdb;<br />
$where = &#8216;WHERE comment_approved = 1 AND user_id &lt;&gt; 0&#8242;;<br />
$comment_counts = (array) $wpdb-&gt;get_results(&#8221;<br />
SELECT user_id, COUNT( * ) AS total<br />
<span style="white-space: pre;"> </span>FROM {$wpdb-&gt;comments}<br />
<span style="white-space: pre;"> </span>{$where}<br />
<span style="white-space: pre;"> </span>GROUP BY user_id<br />
<span style="white-space: pre;"> </span>&#8220;, object);<br />
foreach ( $comment_counts as $count ) {<br />
$user = get_userdata($count-&gt;user_id);<br />
echo &#8216;User &#8216; . $user-&gt;display_name . &#8216; comment count is &#8216; . $count-&gt;total . &#8216;<br />
&#8216;;<br />
}<br />
?&gt;</td>
</tr>
</tbody>
</table>
<h2>How to Create a Tweetmeme “Retweet” shortcode</h2>
<p>Without any doubt, twitter is one of the best ways to get quality traffic to your blog. Of course, you can use several plugins to display this but if you want to do it the pro way then you might want to consider this. The code will display how many times your post has been retweeted.</p>
<p>Just paste the code below into your functions.php file and bingo!</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">function tweetmeme(){</p>
<p>return &#8216;&lt;div class=&#8221;tweetmeme&#8221;&gt;&lt;script type=&#8221;text/javascript&#8221; src=&#8221;http://tweetmeme.com/i/scripts/button.js&#8221;&gt;&lt;/script&gt;&lt;/div&gt;&#8217;;</p>
<p>}</p>
<p>add_shortcode(&#8216;tweet&#8217;, &#8216;tweetmeme&#8217;);</td>
</tr>
</tbody>
</table>
<p><span style="white-space: pre;"> </span><br />
Once the file has been saved, you can display the “retweet” button almost anywhere on your posts. When writing a post, simply insert the below code (make sure you are in html mode when inserting the code).</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">[tweet]</td>
</tr>
</tbody>
</table>
<p><span style="white-space: pre;"> </span><br />
When you publish the post, the shortcode [tweet] will be replaced by the TweetMeme button.</p>
<h2>How to get tags related to category</h2>
<p>This is one of my favorite hack and I am sure you will love it too. This will allow you to get tags related to one or more specific category.</p>
<p>Paste the code in your functions.php file</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">function get_category_tags($args) {</p>
<p>global $wpdb;<br />
<span style="white-space: pre;"> </span>$tags = $wpdb-&gt;get_results<br />
<span style="white-space: pre;"> </span>(&#8221;<br />
<span style="white-space: pre;"> </span>SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link<br />
<span style="white-space: pre;"> </span>FROM<br />
<span style="white-space: pre;"> </span>wp_posts as p1<br />
<span style="white-space: pre;"> </span>LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID<br />
<span style="white-space: pre;"> </span>LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id<br />
<span style="white-space: pre;"> </span>LEFT JOIN wp_terms as terms1 ON t1.term_id = terms1.term_id,<br />
<span style="white-space: pre;"> </span>wp_posts as p2<br />
<span style="white-space: pre;"> </span>LEFT JOIN wp_term_relationships as r2 ON p2.ID = r2.object_ID<br />
<span style="white-space: pre;"> </span>LEFT JOIN wp_term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id<br />
<span style="white-space: pre;"> </span>LEFT JOIN wp_terms as terms2 ON t2.term_id = terms2.term_id<br />
<span style="white-space: pre;"> </span>WHERE<br />
<span style="white-space: pre;"> </span>t1.taxonomy = &#8216;category&#8217; AND p1.post_status = &#8216;publish&#8217; AND terms1.term_id IN (&#8220;.$args['categories'].&#8221;) AND<br />
<span style="white-space: pre;"> </span>t2.taxonomy = &#8216;post_tag&#8217; AND p2.post_status = &#8216;publish&#8217;<br />
<span style="white-space: pre;"> </span>AND p1.ID = p2.ID<br />
<span style="white-space: pre;"> </span>ORDER by tag_name<br />
<span style="white-space: pre;"> </span>&#8220;);<br />
<span style="white-space: pre;"> </span>$count = 0;<br />
<span style="white-space: pre;"> </span>foreach ($tags as $tag) {<br />
<span style="white-space: pre;"> </span>$tags[$count]-&gt;tag_link = get_tag_link($tag-&gt;tag_id);<br />
<span style="white-space: pre;"> </span>$count++;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>return $tags;</p>
<p>}</td>
</tr>
</tbody>
</table>
<p><span style="white-space: pre;"> </span><br />
Once you have done that, use the below code in your theme</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">$args = array(&#8216;categories&#8217; =&gt; &#8217;12,13,14&#8242;);<br />
$tags = get_category_tags($args);
</td>
</tr>
</tbody>
</table>
<h2>How to Get all Custom fields from a Page or a Post</h2>
<p>This code will allow you to get all the custom fields from a specific post or page. Paste the code below in your  functions.php file</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">function all_my_customs($id = 0){<br />
//if we want to run this function on a page of our choosing them the next section is skipped.<br />
//if not it grabs the ID of the current page and uses it from now on.<br />
if ($id == 0) :</p>
<p>global $wp_query;<br />
$content_array = $wp_query-&amp;gt;get_queried_object();<br />
$id = $content_array-&amp;gt;ID;<br />
endif;</p>
<p>//knocks the first 3 elements off the array as they are WP entries and i dont want them.<br />
$first_array = array_slice(get_post_custom_keys($id), 3);<br />
//first loop puts everything into an array, but its badly composed<br />
foreach ($first_array as $key =&amp;gt; $value) :<br />
$second_array[$value] =  get_post_meta($id, $value, FALSE);<br />
//so the second loop puts the data into a associative array<br />
foreach($second_array as $second_key =&amp;gt; $second_value) :<br />
$result[$second_key] = $second_value[0];<br />
endforeach;</p>
<p>endforeach;<br />
//and returns the array.<br />
return $result;</p>
<p>}</td>
</tr>
</tbody>
</table>
<p><span style="white-space: pre;"> </span><br />
You can use the function with the following code</p>
<table border="1" cellpadding="6" width="100%">
<tbody>
<tr>
<td align="left" bgcolor="lightgray">$result = all_my_customs();<br />
echo $result['my_meta_key'];</td>
</tr>
</tbody>
</table>
<p><span style="white-space: pre;"> </span><span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span><br />
I hope you find this useful. Make sure you know your stuff well before applying all these. I have pretty good knowledge of photoshop as well as coding to some extent so if you need any assistance just reply through comments and i will try to get back to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mastermindblogger.com/2009/top-8-wordpress-tricks-and-hacks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

