下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。内存溢出小编现在分享给大家,也给大家做个参考。
重要的事情只说一遍:这是本站首个自制的模板-友情墙,使用 wpdb 自定义去查询友情数据表,设计 CSS,首次弄这些,时间花得挺多呀,不熟悉 WP 的手册就是头痛的回事。要使用这种风格的友情链接,只需新建一个 PHP,把下面的代码复过去就行,然后再像其它页面一样添加一个,选上这个模板就 OK 了。
<?PHP
/**
* Template name: 友情墙
*/
get_header(); ?>
<main >
<div >
<?PHP if (have_posts()): ?>
<?PHP while (have_posts()) : the_post(); ?>
<h1 ><?PHP the_Title(); ?></h1>
<article >
<?PHP the_content(); ?>
</article>
<?PHP enDWhile; ?>
<?PHP endif; ?>
<style>
.clearfix {zoom:1;}
.clearfix:after {content:”.”;display:block;visibility:hIDden;height:0;clear:both;}
.readers-List {List-style:none;}
.readers-List *{margin:0;padding:0;}
.readers-List li{position:relative;padding:10px;float:left;margin-top:20px!important;}
.readers-List li > a {
border: 1px solID #eee;
display: block;
height: 85px;
text-align: center;
Transition:all .5s;
background: #f9f9f9;
}
.readers-List li>a:hover{border-color:#e5e5e5;}
.readers-List a:hover em{top:45px;Font-size:1.1em;}
.readers-List a:hover span{opacity:1;left:50%;}
.readers-List img{position:absolute;top:-30px;left:calc(50% - 30px);wIDth:60px;height:60px;border-radius:50%;0px 0px 10px 5px #008EC2;Box-shadow:0 0 6px 3px #0081B1;Transition:all 1s;background:#fff;}
.readers-List a:hover img {
-webkit-transform:scale(.7);
-moz-transform:scale(.7);
-o-transform:scale(.7);
-ms-transform:scale(.7);
transform:scale(.7);
border-radius: 0;
}
.readers-List em{
position: absolute;
top: 60px;
-webkit-transform: translateX(-50%);
left: 50%;
Font-style: normal;
Font-size: 1.2em;
color: #818181;
Transition: all .3s;
Font-family: Helvetica,Arial,"PingFang SC","Microsoft YaHei","WenQuanYi Micro Hei","tohoma,sans-serif"
}
.readers-List span {
position: absolute;
left: 20%;
bottom: 14px;
overflow: hIDden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
-webkit-transform: translateX(-50%);
wIDth: calc(100% - 30px);
opacity: 0;
Transition:all .3s;
color: #818181;
Font-family: Helvetica,sans-serif"
}
@media(min-wIDth:768px){
.readers-List li{wIDth:25%;}
}
@media(max-wIDth:767px){
.readers-List li{wIDth:100%;}
}
</style>
<div>
<?PHP
global $wpdb;
$qlink="select link_url,link_name,link_image,link_notes,link_description from wp_links where link_visible='Y' order by link_ID";
$links = $wpdb->get_results($qlink);
if(empty($links)) {echo '<p>暂无友链数据!</p>';}
foreach ($links as $comment){
$tmp = "<li><a rel="nofollow" title=".$comment->link_url." target="_blank" href="/go?url=".$comment->link_url.""><img src=".$comment->link_image." alt=""><em>".$comment->link_name."</em><span>".$comment->link_notes."</span></a></li>";
$output1 .= $tmp;
}
$output1 = "<ul >".$output1."</ul>";
echo $output1;
?>
</div>
<?PHP
if(comments_open()){
comments_template();
}else{
echo "<h5>评论已经关闭</h5>";
}
?>
</div>
</main>
<?PHP get_footer(); ?>
以下是最终的效果图:
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的友情墙 - 自定义友情链接页面模板全部内容,希望文章能够帮你解决友情墙 - 自定义友情链接页面模板所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)