WordPress给模板添加友情链接页面

/ 9评 / 0

因为这个模板没有友情链接页面,而我之前与其他人换过友情链接,我就有必要自己添加一个友情链接页面。

首先,复制page.php文件并剪贴重命名为link-page.php,打开link-page.php找到<?php the_content(); ?>替换为如下代码

<div class="links">
 <?php
 $bookmarks = get_bookmarks('title_li=&orderby=rand'); //全部链接随机输出
 if ( !empty($bookmarks) ){
 foreach ($bookmarks as $bookmark) {
 $friendimg = $bookmark->link_image;
 echo '<a class="link" href="' . $bookmark->link_url . '" target="_blank" style="margin: 0;">
<img src="'. $bookmark->link_image. '" style="cursor: pointer; display: block; margin: 0 auto;">
<div class="sitename">'. $bookmark->link_name .'</div>
<div class="siteinfo">' . $bookmark->link_description . '</div></a>'
;
 }
 }
 ?>
</div>

如果你想要在友情链接页面显示页面文章内容的话,在</div>后加入<?php the_content(); ?>即可,然后你只需要在后台的链接中添加链接即可

没有链接的,打开你的functions.php,在结尾添加如下代码即可

add_filter( 'pre_option_link_manager_enabled', '__return_true' );

完成如上步骤后你只需要新建一个页面使其别名为links即可看到你的友情链接页面,以及你添加的友情链接了!

什么?不美观?在你的css文件中添加如下代码即可

.link{outline: none; color: #444;float: left; width: 50%; text-align: center; border-radius: 5px; transition: all .3s ease-in-out;margin-top: 10px;cursor: pointer;}
.link:hover{background-color: #eee}
.link img{width: 70px; height: 70px; border-radius: 70px; margin: 5px 10px !important; transition: all .3s ease-in-out; float: left;}
.link .sitename{font-weight: bold; font-size: 20px; margin-top: 10px;cursor: pointer;}
.link .siteinfo{color: #777; margin-top: 10px; overflow: hidden; text-overflow: ellipsis;}
.links a{text-decoration: none;}

文章若未注明则均为原创,转载请注明来源自豆博客-WordPress给模板添加友情链接页面

9条回应:“WordPress给模板添加友情链接页面”

  1. Turkije Visums说道:

    Wow, fantastic weblog layout! How lengthy have you been blogging for?
    you made running a blog glance easy. The full glance of your website is great, as well as the content!

    • Mr.Bean说道:

      @Turkije Visums Yes, my friend, I like simple things. I have been blogging for more than a year. This blog uses Adams theme of WordPress. I really feel like it and your comments. This makes me continue to write. I hope you can see and comment on it regularly.(My English is not good,So the above content is translated using Baidu translation, including this one.)

  2. Turkije Visums说道:

    I got this web site from my buddy who informed me about this
    web site and at the moment this time I am browsing this site and reading very informative posts at this time.

  3. lubin说道:

    Hey there! This post couldn’t be written any better!

    Reading this post reminds me of my good old room mate!
    He always kept talking about this. I will forward this
    write-up to him. Fairly certain he will have a good read.
    Thanks for sharing!

  4. Howdy! I know this is kinda off topic but I was wondering
    which blog platform are you using for this site?
    I’m getting tired of WordPress because I’ve had issues with hackers and I’m looking at options for another platform.
    I would be fantastic if you could point
    me in the direction of a good platform.

    • Mr.Bean说道:

      @plenty of fish dating site Hey, my friend, it’s unfortunate to tell you that I use WordPress now, but I have several good blog platforms, but they are in Chinese. If you don’t suggest, you can try to use them, such as emlog (maybe some security issues), zblog, Typecho (lightweight blog platform).
      I don’t think WordPress has any security problems. As long as you make sure the version update of WordPress and the security of the server, your website will be very secure, and you don’t need to worry about hackers any more.

    • Mr.Bean说道:

      @plenty of fish dating site If you have any other questions, please come here to comment.

发表评论

电子邮件地址不会被公开。 必填项已用*标注