發表文章

目前顯示的是 7月 28, 2013的文章

Display Related Posts in WordPress without a Plugin

Display Related Posts in WordPress without a Plugin Paste the following code in   single.php   where you want to display related posts view source print ? 01 <?php 02 //for use in the loop, list 5 post titles related to first tag on current post 03 $tags   = wp_get_post_tags( $post ->ID); 04 if   ( $tags ) { 05 echo   'Related Posts' ; 06 $first_tag   =   $tags [0]->term_id; 07 $args = array ( 08 'tag__in'   =>   array ( $first_tag ), 09 'post__not_in'   =>   array ( $post ->ID), 10 'posts_per_page' =>5, 11 'caller_get_posts' =>1 12 ); 13 $my_query   =   new   WP_Query( $args ); 14 if (   $my_query ->have_posts() ) { 15 while   ( $my_query ->have_posts()) :   $my_query ->the_post(); ?> 16 <a href= "<?php the_permalink() ?>"   rel= "bookmark" title= "Permanent Link to ...