groups

name language licence
Custom post title with lead graphic background PHP BSD
Create A Maintenance Page For Your WordPress Blog HTML BSD
Display Related Posts Without A Plug-In PHP BSD
Resize Images On The Fly PHP BSD
opacity background PHP BSD
Untitled Snippet PHP BSD
Custom Fonts using @font-face HTML BSD



language: PHP
licence: BSD

Display Related Posts Without A Plug-In

options: view full snippetsend to code collector
//The problem. One well-known way of keeping visitors on your blog longer and helping them discover news posts is to display, usually at the end of the article, a list of related content.
Many plug-ins will do this job, but why not super-charge your theme by integrating this functionality by default?
The solution.
Open the single.php file in your theme.
Paste the following code in the loop:

<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
  echo 'Related Posts';
  $first_tag = $tags[0]->term_id;
  $args=array(
    'tag__in' => array($first_tag),
    'post__not_in' => array($post->ID),
	
(Continues...)