wordpress评论与推荐块位置不同,就会出错
在wordpress的single.php页面
我想加入一个推荐内容板块.就是根据当前文章的分类ID查询类似的文章然后作为推荐
但是
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <?php comments_template(); ?> <?php include_once 'recommend.php';?>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <?php include_once 'recommend.php';?> <?php comments_template(); ?>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <div id="recommend"> <?php //获取当前分类名 $cat_name = single_cat_title('',false); //获取分类ID $cat_id = get_cat_ID($cat_name); $args=array('cat'=>$cat_id,'showposts'=>5); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> <li> <span> if ( has_post_thumbnail() ) { ?> <img src="<?php%20get_image_url();%20?>" alt="" title="<?php echo short_title('...', 5); ?>"></span> }else{?> <img src="<?php%20bloginfo('template_directory');%20?>/images/dummy.png" alt="" title="<?php echo short_title('...', 5); ?>"> }?> <p><a href="<?php%20the_permalink()%20?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p> </li> <?php endwhile; ?> </div> <div class="clear"></div>