在网站中添加每日60秒读懂世界(已失效)

在网站中添加每日60秒读懂世界(已失效)

方法一:图片版(最简单)

发布一篇文章

在文章里面添加一下代码即可

不要使用可视化编辑

使用文本模式

<img src="https://v2.alapi.cn/api/zaobao?token=qhN3dgYvfebGVXnc&amp;format=image" />

方法二

这种会相对麻烦一点,要在源码后台修改,也是本博客在使用的,用到的地方也是两处

1.functions.php(在使用的主题文件里可以看到这个,一般在主题目录下)

在functions.php下添加以下代码

function ttsistens(){//60s
  $sixs = json_decode(file_get_contents("https://www.zhihu.com/api/v4/columns/c_1261258401923026944/items"),true)['data'][0]['content'];
  return $sixs;
};

2.page

在主题的pages下新建ttsixs.php复制以下代码保存即可(部分数据自行修改)

<?php

/**
 * Template name: 每日60s
 * Description:   60S
 */

get_header();
?>
<style>
.sixten{width:80%;margin:0 auto 20px auto;padding:24px;}
@media (max-width:1030px){.sixten{width:100%;}}
@media screen and (min-width:800px) and (max-width:1007px){.tens p:nth-child(4){padding:20px !important;}}
@media (min-width:800px){
.sixten>p{font-size:18px;padding:8px}
.tens p:first-child{padding:0}
.tens p:nth-child(3){width: 18%;border:2px solid #848484;margin-top:10px;padding:16px;display: inline-block;font-size:14px;border-radius:10px;}
.tens p:nth-child(4){float: right;width:80%;border:2px solid #848484;border-bottom:2px solid #848484;margin-top:10px;border-right:0;border-left:0;font-size:36px;display:inline-block;padding:10px;text-align:center;color:#f00;}
p.overclass{font-size:24px;}
}
p.overclass{text-align:center;color:#f1420d;letter-spacing:2px;padding-top:40px;}
.url{display:none;}
</style>
<main role="main" class="container">
<div class="zib-widget sixten" style="padding: 24px 24px 6px 24px;"><h3 class="title-h-center text-center">每天60秒,读懂世界</h3></div>
<div class="zib-widget sixten tens">
    <?php echo ttsistens()?>
    <div style="background:#7d7d7d;width:100%;height:2px;margin-bottom:2px;margin-top:20px;"></div>
    <div style="background:#7d7d7d;width:100%;height:1px;margin-bottom: 22px;"></div>
    <div style="background:#7d7d7d;width:100%;height:1px;margin-bottom: 2px;margin-top:20px;"></div>
    <div style="background:#7d7d7d;width:100%;height:2px;margin-bottom: 22px;"></div>
    <p class="overclass"><strong>--- 感谢您的来访,本文每日更新 ---</strong></p>
</div>
</main>
<?php
get_footer();

接下来新建页面选择 ( 60S) 模板保存即可,剩下的就不说了自己琢磨!

THE END
喜欢就支持一下吧
点赞5赞赏 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容