提醒:本文最后更新于 4178 天前,文中所描述的信息可能已发生改变,请仔细核实。
无觅,一直外链什么的,很讨厌,要不是会相关文章和自动微博。老子还真不想用。
现在把无觅淘汰掉,估计要重新找个自动关联所有的插件,不过无所谓啦。起码不用无觅的相关文章。。。这玩意经常是连到他那里,在转接过来。。。靠,偶极度不爽。
效果图:
这样看起来还是不错的。
本次主要是改了css和php。
现在放出来。
将loper的style.css中relate标签分隔栏替换成下面内容
/*--Relate--*/
.relatebar{clear:both; margin:10px 0;}.relatebar .Related_Posts{margin-top:9px; margin-left:15px; width:700px}.relatebar .Related_Posts_tittle{margin-top:3px; line-height:17px; color:#515151 !important; font-size:12px !important; width:112px; overflow:hidden}.relatebar .Related_Posts li{float:left; margin:0 32px 0 0;display: block;}.relatebar .Related_Posts ul li img{width:90px; height:90px; background:#F4F4F4; border:1px solid #D8D8D8; padding:2px}
.relatebar{clear:both; margin:10px 0;}.relatebar .Related_Posts{margin-top:9px; margin-left:15px; width:700px}.relatebar .Related_Posts_tittle{margin-top:3px; line-height:17px; color:#515151 !important; font-size:12px !important; width:112px; overflow:hidden}.relatebar .Related_Posts li{float:left; margin:0 32px 0 0;display: block;}.relatebar .Related_Posts ul li img{width:90px; height:90px; background:#F4F4F4; border:1px solid #D8D8D8; padding:2px}
接着在loper的single.php中的
<ul>
<?php
$post_tags = wp_get_post_tags($post->ID);
if ($post_tags) {
foreach ($post_tags as $tag)
{$tag_list[] .= $tag->term_id;}
$post_tag = $tag_list[ mt_rand(0, count($tag_list) - 1) ];
$args = array(
'tag__in' => array($post_tag),
'category__not_in' => array(NULL),
'post__not_in' => array($post->ID),
'showposts' => 6,
'caller_get_posts' => 1
);
query_posts($args);
if (have_posts()) :
while (have_posts()) : the_post(); update_post_caches($posts); ?>
<li><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; else : ?>
<li>暂无相关文章</li>
<?php endif; wp_reset_query(); } ?>
</ul>
<?php
$post_tags = wp_get_post_tags($post->ID);
if ($post_tags) {
foreach ($post_tags as $tag)
{$tag_list[] .= $tag->term_id;}
$post_tag = $tag_list[ mt_rand(0, count($tag_list) - 1) ];
$args = array(
'tag__in' => array($post_tag),
'category__not_in' => array(NULL),
'post__not_in' => array($post->ID),
'showposts' => 6,
'caller_get_posts' => 1
);
query_posts($args);
if (have_posts()) :
while (have_posts()) : the_post(); update_post_caches($posts); ?>
<li><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; else : ?>
<li>暂无相关文章</li>
<?php endif; wp_reset_query(); } ?>
</ul>
替换为:
<div class="clear"></div>
<div class="Related_Posts"><ul><?php $post_num = 4;$exclude_id = $post->ID;$posttags = get_the_tags(); $i = 0;if ( $posttags ) {$tags = ''; foreach ( $posttags as $tag ) $tags .= $tag->term_id . ',';$args = array('post_status' => 'publish','tag__in' => explode(',', $tags),'post__not_in' => explode(',', $exclude_id),'ignore_sticky_posts' => 1,'orderby' => 'comment_date','posts_per_page' => $post_num);query_posts($args);while( have_posts() ) { the_post(); ?><li><a href="<?php the_permalink(); ?> " rel="nofollow"><?php post_thumbnail( 90,90 ); ?></a><div class="Related_Posts_tittle"><a class="Related_Posts_tittle" href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></div></li><?php $exclude_id .= ',' . $post->ID; $i ++;} wp_reset_query();}if ( $i < $post_num ) {$cats = ''; foreach ( get_the_category() as $cat ) $cats .= $cat->cat_ID . ',';$args = array('category__in' => explode(',', $cats),'post__not_in' => explode(',', $exclude_id),'ignore_sticky_posts' => 1,'orderby' => 'comment_date','posts_per_page' => $post_num - $i);query_posts($args);while( have_posts() ) { the_post(); ?><li><a href="<?php the_permalink(); ?> " rel="nofollow"><?php post_thumbnail( 90,90 ); ?></a><div class="Related_Posts_tittle"><a class="Related_Posts_tittle" href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></div></li><?php $i++;} wp_reset_query();}if ( $i == 0 ) echo '<li>没有相关文章!</li>';?></ul></div>
<div class="clear"></div>
<div class="Related_Posts"><ul><?php $post_num = 4;$exclude_id = $post->ID;$posttags = get_the_tags(); $i = 0;if ( $posttags ) {$tags = ''; foreach ( $posttags as $tag ) $tags .= $tag->term_id . ',';$args = array('post_status' => 'publish','tag__in' => explode(',', $tags),'post__not_in' => explode(',', $exclude_id),'ignore_sticky_posts' => 1,'orderby' => 'comment_date','posts_per_page' => $post_num);query_posts($args);while( have_posts() ) { the_post(); ?><li><a href="<?php the_permalink(); ?> " rel="nofollow"><?php post_thumbnail( 90,90 ); ?></a><div class="Related_Posts_tittle"><a class="Related_Posts_tittle" href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></div></li><?php $exclude_id .= ',' . $post->ID; $i ++;} wp_reset_query();}if ( $i < $post_num ) {$cats = ''; foreach ( get_the_category() as $cat ) $cats .= $cat->cat_ID . ',';$args = array('category__in' => explode(',', $cats),'post__not_in' => explode(',', $exclude_id),'ignore_sticky_posts' => 1,'orderby' => 'comment_date','posts_per_page' => $post_num - $i);query_posts($args);while( have_posts() ) { the_post(); ?><li><a href="<?php the_permalink(); ?> " rel="nofollow"><?php post_thumbnail( 90,90 ); ?></a><div class="Related_Posts_tittle"><a class="Related_Posts_tittle" href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></div></li><?php $i++;} wp_reset_query();}if ( $i == 0 ) echo '<li>没有相关文章!</li>';?></ul></div>
<div class="clear"></div>
如此便ok了!
转载请注明转自:kn007的个人博客的《给loper加上缩略图相关文章,淘汰无觅》
早,我起来抢票了。
@乐猪: 祝你成功
苦逼饿,我还在用无米
@Mikeyzm: 无觅是方便了点,但是最近无觅js加载好慢。。
略缩图自动生成?
@老猫Music: 调用生成好的,自己写的函数。