wordpress调用「ONE」一个,小清新

    看到很多朋友都在做自己的博客,全是小清新有木有?被你们的心灵鸡汤完全同化了,今天主题笔记就给小清新的站长们推荐更加有逼格的功能——调用韩寒的「ONE」一个

    效果图:

    one

    相关代码:

    [login]

    function the_one(){
            $json = get_one_json();
            $content = $json['hpEntity'];
            $image = $content['strOriginalImgUrl'];
            $data = date("Y-m-d",time());
            $author = $content['strAuthor'];
            $words = $content['strContent'];
            $output = '<div id="one--feed">';
            $output .= '<div class="oneContent">'.$words.'<span style="float:right;padding:0 20px">'.$data.'</span></div></div>';
            return $output;
        }
    
        function get_one_json(){
            if (get_transient('onecache')) {
                $content = get_transient('onecache');
            }else{
                delete_transient('onecache');
                $data = date("Y-m-d",time());
                $getjson = 'http://211.152.49.184:7001/OneForWeb/one/getHpinfo?strDate=' . $data;
                $content = file_get_contents($getjson);
                set_transient('onecache', $content, 60*60*24);
            }
            return json_decode($content,true); 
        }

    [/login]
    将上面的代码放在functions.php中

    最后在需要显示的地方打印输出 the_one() 即可,相关样式根据自己需要自行调整,这里就不给出相应的CSS代码了。

    Responses

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

    Up Next:

    ajax无刷新手动加载分页文章

    ajax无刷新手动加载分页文章