TutZone- Tutorials, Design news and Inspiration | ![]() |
Post Treatment – Show Related Posts Without a Plugin Posted: 06 May 2010 05:28 AM PDT Using too many plugins on a Wordpress installation usually slower the loading time of the site, especially when same can be achieved using a simple piece of code. Though its not always wise to use codes in your wordpress themes, especially if you are not familiar with them. Here we will show you how to Show Related Posts Without Plugin which will be based on the tags you will use in your posts. Hope this helps some. You may also want to go through previous Resources: Procesure:Note: Do take backup of your theme before you try this. 01. Go to Appearance => Editor. 02. Then choose functions.php file from right hand side and add below code: function related_posts_shortcode( $atts ) { extract(shortcode_atts(array( ‘limit’ => ‘5′, ), $atts)); global $wpdb, $post, $table_prefix; if ($post->ID) { // Do the query $related = $wpdb->get_results($q); 03. Save file. Now open single.php file and place following lines where you want your Related Posts to appear: [related_posts] 04. Save file and you are done. For New Wordpress Users:You can try out following recommended plugins: Yet Another Related Posts Plugin Further Resources:That concludes this simple and useful tutorial. Hope you like it. |
You are subscribed to email updates from TutZone To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment