简单用代码实现wordpress显示相关文章

很多人会使用外挂来显示文章内的相关文章
或是使用主题内建的功能,在文章中显示相关文章
但我个人则喜好清爽的显示方法
以及简单的实现方式
也是有人问我,我的相关文章是怎么做出来的
做法很简单,我就来分享一下
开启主题的single.php如下图

简单用代码实现wordpress显示相关文章

在single.php里面找到这段 

简单用代码实现wordpress显示相关文章

后面加入以下代码

[cc lang="php"]

▉▉推荐阅读
    cat_ID; } query_posts('cat=' . $cat . '&orderby=rand&showposts=10'); //控制相關文章排序為隨機,顯示5篇相關文章 while (have_posts()) : the_post(); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); ?>

[/cc]

在你的主题css中加入以下代码

[emaillocker] [cc lang="php"] .wrapper112{ clear: both; height: 100%; position: relative; color: #444; overflow: hidden; border: 0px solid #CCC; border-radius: 5px; font -family: Verdana,Arial,Helvetica,sans-serif; line-height: 26px; font-size: 20px; padding: 5px; } .toky_ooo li a:hover{color:#fff;background:#0099cb;border-color :#0099cb;} .toky_ooo li{float:left;list-style-type:none;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;} .toky_ooo li a {display:block;width:100%;height:100%;color:#232323;text-decoration:none;background:#f1f1f1;-moz-box-shadow:1px 1px 3px #666;-webkit-box-shadow :1px 1px 3px #666;box-shadow:1px 1px 3px #666;-moz-border-radius:8px;-webkit-border-radius:8px;;margin:6px 5px 9px 0;padding:5px;} [/ cc]

那么你可以自行修改css的样式

[/emaillocker]

评论 (0)

此处尚未发表评论

留言

  1. 以游客身份发表评论。注册登入到您的帐户。
附件 (0/ 3)
分享您的位置