Wednesday, 11 June 2014

How to add Related Post in Wordpress Without a pluin

You can done this by tow ways , one by tags and another by category. So how to do this?




related post in wordpress by Category



1. Add this code in functions.php



    add_theme_support( 'post-thumbnails' );  
    set_post_thumbnail_size( 150, 150, true );


2. Then add this codode in single.php




    




3.Add Some css to your style.css








.relatedposts {width: 640px; margin: 0 0 20px 0; float: left; font-size: 12px;}
.relatedposts h3 {font-size: 20px; margin: 0 0 5px 0; }
.relatedthumb {margin: 0 1px 0 1px; float: left; }
.relatedthumb img {margin: 0 0 3px 0; padding: 0;}
.relatedthumb a {color :#333; text-decoration: none; display:block; padding: 4px; width: 150px;}
.relatedthumb a:hover {background-color: #ddd; color: #000;}

                  
				  




related post in wordpress by tag





add this code in functions.php





    add_theme_support( 'post-thumbnails' );  
    set_post_thumbnail_size( 150, 150, true );

                  
				  




Then add this codode in single.php









3 Some css style





.relatedposts {width: 640px; margin: 0 0 20px 0; float: left; font-size: 12px;}
.relatedposts h3 {font-size: 20px; margin: 0 0 5px 0; }
.relatedthumb {margin: 0 1px 0 1px; float: left; }
.relatedthumb img {margin: 0 0 3px 0; padding: 0;}
.relatedthumb a {color :#333; text-decoration: none; display:block; padding: 4px; width: 150px;}
.relatedthumb a:hover {background-color: #ddd; color: #000;}

                  
				  

No comments:

Post a Comment