<?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>The Tech Space &#187; hacks</title>
	<atom:link href="http://www.thetechspace.com/tag/hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetechspace.com</link>
	<description>php, jquery, flash and resources</description>
	<lastBuildDate>Fri, 21 May 2010 08:12:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Useful WordPress Hacks</title>
		<link>http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/</link>
		<comments>http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 15:18:38 +0000</pubDate>
		<dc:creator>Thurein</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.thetechspace.com/?p=228</guid>
		<description><![CDATA[Show related post without a plugin
If you want to show related post in you current post , you can use simple way to show. You just need to copy and paste under following codes into single.php file of your theme. This code will display related posts based on the current post tag(s). It must be [...]]]></description>
			<content:encoded><![CDATA[<h3>Show related post without a plugin</h3>
<p>If you want to show related post in you current post , you can use simple way to show. You just need to copy and paste under following codes into <strong>single.php</strong> file of your theme. This code will display related posts based on the current post tag(s). It must be pasted <strong>within</strong> the loop.</p>
<pre class="brush:php">

&lt;?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post-&gt;ID);
if ($tags) {
 echo 'Related Posts';
 $first_tag = $tags[0]-&gt;term_id;
 $args=array(
 'tag__in' =&gt; array($first_tag),
 'post__not_in' =&gt; array($post-&gt;ID),
 'showposts'=&gt;5,
 'caller_get_posts'=&gt;1
 );
 $my_query = new WP_Query($args);
 if( $my_query-&gt;have_posts() ) {
 while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt;
 &lt;p&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;/p&gt;
 &lt;?php
 endwhile;
 }
}
?&gt;
</pre>
<p>source : <a href="http://www.wprecipes.com/how-to-show-related-posts-without-a-plugin" target="_blank">How to: Show related posts without a plugin</a></p>
<p><span id="more-228"></span></p>
<h3>Create WordPress Shortcode for related posts</h3>
<p>You can use WordPress shortcode too.</p>
<p>To create the shortcode, simply open your functions.php file and paste the shortcode function:</p>
<pre class="brush:php">
function related_posts_shortcode( $atts ) {
 extract(shortcode_atts(array(
 'limit' =&gt; '5',
 ), $atts));

 global $wpdb, $post, $table_prefix;

 if ($post-&gt;ID) {
 $retval = '&lt;ul&gt;';
 // Get tags
 $tags = wp_get_post_tags($post-&gt;ID);
 $tagsarray = array();
 foreach ($tags as $tag) {
 $tagsarray[] = $tag-&gt;term_id;
 }
 $tagslist = implode(',', $tagsarray);

 // Do the query
 $q = &quot;SELECT p.*, count(tr.object_id) as count
 FROM $wpdb-&gt;term_taxonomy AS tt, $wpdb-&gt;term_relationships AS tr, $wpdb-&gt;posts AS p WHERE tt.taxonomy ='post_tag' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id  = p.ID AND tt.term_id IN ($tagslist) AND p.ID != $post-&gt;ID
 AND p.post_status = 'publish'
 AND p.post_date_gmt &lt; NOW()
 GROUP BY tr.object_id
 ORDER BY count DESC, p.post_date_gmt DESC
 LIMIT $limit;&quot;;

 $related = $wpdb-&gt;get_results($q);
 if ( $related ) {
 foreach($related as $r) {
 $retval .= '
 &lt;li&gt;&lt;a title=&quot;'.wptexturize($r-&gt;post_title).'&quot; href=&quot;'.get_permalink($r-&gt;ID).'&quot;&gt;'.wptexturize($r-&gt;post_title).'&lt;/a&gt;&lt;/li&gt;
';
 }
 } else {
 $retval .= '
 &lt;li&gt;No related posts found&lt;/li&gt;
';
 }
 $retval .= '&lt;/ul&gt;
';
 return $retval;
 }
 return;
}
add_shortcode('related_posts', 'related_posts_shortcode');
</pre>
<p>Once done, you can use the following shortcode in your posts to display the related content:</p>
<pre class="brush:html">
[related_posts]
[/pre>

Source : <a href="http://www.wprecipes.com/wordpress-shortcode-to-display-related-posts" target="_blank">WordPress shortcode to display related posts</a>
<h3>Show related post from same category</h3>

If you want to get related post base on category , you can simply add some code in <strong>function.php</strong> file. It displays posts depending of the category. This function have three parameters -
<ul>
<li> $limit (int) amount of posts to display</li>
<li>$catName (bool) echo category name, TRUE or FALSE</li>
<li>$title (string) String for a text before all entries</li>
</ul>
<pre class="brush:php">

/**
 * related post with category
 * @param: int $limit limit of posts
 * @param: bool $catName echo category name
 * @param: string $title string before all entries
 * Example: echo fb_cat_related_posts();
 */
if ( !function_exists('fb_get_cat_related_posts') ) {
 function fb_get_cat_related_posts( $limit = 5, $catName = TRUE, $title = '&lt;h3&gt;Recent Pages&lt;/h3&gt;' ) {

 if ( !is_single() )
 return;

 $limit = (int) $limit;
 $output  = '';
 $output .= $title;

 $category = get_the_category();
 $category = (int) $category[0]-&gt;cat_ID;

 if ( $catName )
 $output .= __( 'Kategorie: ' ) . get_cat_name($category) . ' ';

 $output .= '&lt;ul&gt;';

 $args = array(
 'numberposts' =&gt; $limit,
 'category' =&gt; $category,
 );

 $recentposts = get_posts( $args );
 foreach($recentposts as $post) {
 setup_postdata($post);
 $output .= '&lt;li&gt;&lt;a href=&quot;' . get_permalink($post-&gt;ID) . '&quot;&gt;' . get_the_title($post-&gt;ID) . '&lt;/a&gt;&lt;/li&gt;';
 }

 $output .= '&lt;/ul&gt;';

 return $output;
 }
}

[/pre>

Source : <a href="http://wpengineer.com/related-posts-on-category/" target="_blank">Related Posts on Category</a>
<h3>Display comments and trackbacks separately</h3>

Let's face it: When you're reading comments on a blog post, trackbacks are annoying. It's way better to display it separately from comments.
Open and edit the comments.php file from your theme.

Find the comment loop:
<pre class="brush:php">
foreach ($comments as $comment) : ?&gt;
 // Comments are displayed here
endforeach;
</pre>
<p>Replace it with the following:</p>
<pre class="brush:php">
&lt;ul&gt;
 &lt;?php //Displays comments only
 foreach ($comments as $comment) : ?&gt;
 &lt;?php $comment_type = get_comment_type(); ?&gt;
 &lt;?php if($comment_type == 'comment') { ?&gt;
 &lt;li&gt;//Comment code goes here&lt;/li&gt;
 &lt;?php }
 endforeach;
&lt;/ul&gt;

&lt;ul&gt;
 &lt;?php //Displays trackbacks only
 foreach ($comments as $comment) : ?&gt;
 &lt;?php $comment_type = get_comment_type(); ?&gt;
 &lt;?php if($comment_type != 'comment') { ?&gt;
 &lt;li&gt;&lt;?php comment_author_link() ?&gt;&lt;/li&gt;
 &lt;?php }
 endforeach;
&lt;/ul&gt;
</pre>
<p>Soruce : <a href="http://www.wprecipes.com/jamie-asked-how-can-i-display-comments-and-trackbacks-separately" target="_blank">Jamie asked: “How can I display comments and trackbacks separately?”</a></p>
<h3>List Future Posts</h3>
<p>If you want to display list of future post what you scheduled to be publish, simply paste this code where you would like to be displayed.</p>
<pre class="brush:php">

&lt;div id=&quot;zukunft&quot;&gt;
 &lt;div id=&quot;zukunft_header&quot;&gt;&lt;p&gt;Future events&lt;/p&gt;&lt;/div&gt;
 &lt;?php query_posts('showposts=10&amp;post_status=future'); ?&gt;
 &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;
 &lt;div &gt;
 &lt;p class&gt;&lt;b&gt;&lt;?php the_title(); ?&gt;&lt;/b&gt;&lt;?php edit_post_link('e',' (',')'); ?&gt;&lt;br /&gt;
 &lt;span&gt;&lt;?php the_time('j. F Y'); ?&gt;&lt;/span&gt;&lt;/p&gt;
 &lt;/div&gt;
 &lt;?php endwhile; else: ?&gt;&lt;p&gt;No future events scheduled.&lt;/p&gt;&lt;?php endif; ?&gt;
&lt;/div&gt;
</pre>
<p>Source : <a href="http://www.wprecipes.com/how-to-list-future-posts" target="_blank">How to: List future posts</a></p>
<h3>Show popular posts without a plugin</h3>
<p>If you want to show popular post in your post or side bar, you just paste following code where you would like to displayed.</p>
<pre class="brush:php">

&lt;h2&gt;Popular Posts&lt;/h2&gt;
&lt;ul&gt;
&lt;?php $result = $wpdb-&gt;get_results(&quot;SELECT comment_count,ID,post_title FROM $wpdb-&gt;posts ORDER BY comment_count DESC LIMIT 0 , 5&quot;);
foreach ($result as $post) {
setup_postdata($post);
$postid = $post-&gt;ID;
$title = $post-&gt;post_title;
$commentcount = $post-&gt;comment_count;
if ($commentcount != 0) { ?&gt;

&lt;li&gt;&lt;a href=&quot;&lt;?php echo get_permalink($postid); ?&gt;&quot; title=&quot;&lt;?php echo $title ?&gt;&quot;&gt;
&lt;?php echo $title ?&gt;&lt;/a&gt; {&lt;?php echo $commentcount ?&gt;}&lt;/li&gt;
&lt;?php } } ?&gt;

&lt;/ul&gt;
</pre>
<p>Source : <a href="http://www.problogdesign.com/wordpress/create-your-own-popular-posts-page/" target="_blank">Create Your Own Popular Post Page</a></p>
<h3>Highlight Searched Text In Search Results</h3>
<p>If you want to highlight searched text in search resualt, you can get after following step.</p>
<p>Open your search.php file and find the the_title() function. Replace it with the following:</p>
<pre class="brush:php">

echo $title;
</pre>
<p>Now, just before the modified line, add this code:</p>
<pre class="brush:php">

&lt;?php
 $title     = get_the_title();
 $keys= explode(&quot; &quot;,$s);
 $title     = preg_replace('/('.implode('|', $keys) .')/iu',
 '&lt;strong&gt; &lt;/strong&gt;',
 $title);
?&gt;
</pre>
<p>Save the search.php file and open style.css. Append the following line to it:</p>
<pre class="brush:css">

strong.search-excerpt { background: yellow; }
</pre>
<p>Source : <a title="Enlight searched text in search results" href="http://www.wprecipes.com/how-to-enlight-searched-text-in-search-results" target="_blank">Enlight searched text in search results</a></pre>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/&amp;title=Useful+WordPress+Hacks" rel="" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/&amp;title=Useful+WordPress+Hacks" rel="" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/&amp;title=Useful+WordPress+Hacks" rel="" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/" rel="" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/&amp;t=Useful+WordPress+Hacks" rel="" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Useful+WordPress+Hacks+-+http://tinyurl.com/yzyg54b+(via+@lit_tiger)&amp;source=shareaholic" rel="" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/&amp;title=Useful+WordPress+Hacks" rel="" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/&amp;imageurl=" rel="" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="sexy-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/&amp;title=Useful+WordPress+Hacks" rel="" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetechspace.com/2009/10/23/useful-wordpress-hacks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
