2012-05-28 27 views
0

我想添加「Readability-Buttons」到我的文章。但插件存在不適合我,因爲我不能改變背景顏色。WordPress的可讀性

所以在可讀性網站:readability.com/publishers/tools我可以做我自己的按鈕。

我怎麼能把這個自動地放在我的所有帖子裏?我想在的functions.php這將是正確的目的地..

此北京時間按鈕的代碼:

<div data-bg-color="#fdfdfa" class="rdbWrapper" data-show-read="1" data-show-send-to-kindle="0" data-show-print="0" data-show-email="0" data-orientation="0" data-version="1"></div><script type="text/javascript">(function() {var s = document.getElementsByTagName("script")[0],rdb = document.createElement("script"); rdb.type = "text/javascript"; rdb.async = true; rdb.src = document.location.protocol + "//www.readability.com/embed.js"; s.parentNode.insertBefore(rdb, s); })();</script> 

感謝提前。

格爾茨邁克

回答

0

我認爲最簡單的方法是將JQ添加到您的頁腳和按鈕添加到您的page.php文件,或者您已進入目錄結束div上面所做的任何自定義頁面。

0

functions.php將是錯誤的地方。請看Wordpress codex瞭解哪些文件屬於哪個文件。

你究竟想把按鈕放在你的頁面上?

最重要的,你可能是:這取決於您的主題

  • page.php文件
  • 靜態頁面

    • 的index.php的single.php的文章, header.php爲頁眉
    • footer.php的頁腳

    如果你把在頁眉或頁腳中的代碼,它會出現在所有頁面上顯示的,如果你不使用任何conditional tags與您可以設置哪些頁面(或頁面類型)顯示按鈕。

  • +0

    謝謝回答。我只希望在每一篇文章中。在帖子的頂部。所以我必須把代碼放入index.php? – racemike

    +0

    這個或single.php,我以前忘了提及 - 取決於你的主題。如果single.php存在,可能你將不得不使用這個。只需備份並嘗試一下,就不會有太大的突破。 –

    0

    正確的位置是functions.php。您添加過濾器,像這樣:

    function add_post_content($content) { 
    $content .= $buttonCode 
    return $content; 
    } 
    add_filter('the_content', 'add_post_content'); 
    

    希望這有助於 傑森

    [更新]

    對於這個我假設你所提供的代碼是按鈕的代碼如果沒有的話只需更換正確的按鈕代碼即可。

    打開你的功能。PHP的theme文件夾中,並在底部添加此:

    說得低於後添加:

    function add_post_content($content) { 
        $buttonCode = "<div data-bg-color=\"#fdfdfa\" class=\"rdbWrapper\" data-show-read=\"1\" data-show-send-to-kindle=\"0\" data-show-print=\"0\" data-show-email=\"0"\ data-orientation=\"0\" data-version=\"1\"></div><script type=\"text/javascript\">(function() {var s = document.getElementsByTagName(\"script\")[0],rdb = document.createElement(\"script\"); rdb.type = \"text/javascript\"; rdb.async = true; rdb.src = document.location.protocol + \"//www.readability.com/embed.js\"; s.parentNode.insertBefore(rdb, s); })();</script>"; 
        $content .= $buttonCode 
        return $content; 
    } 
    add_filter('the_content', 'add_post_content'); 
    

    要放在它上面的帖子你加:

    function add_post_content($content) { 
        $buttonCode = "<div data-bg-color=\"#fdfdfa\" class=\"rdbWrapper\" data-show-read=\"1\" data-show-send-to-kindle=\"0\" data-show-print=\"0\" data-show-email=\"0"\ data-orientation=\"0\" data-version=\"1\"></div><script type=\"text/javascript\">(function() {var s = document.getElementsByTagName(\"script\")[0],rdb = document.createElement(\"script\"); rdb.type = \"text/javascript\"; rdb.async = true; rdb.src = document.location.protocol + \"//www.readability.com/embed.js\"; s.parentNode.insertBefore(rdb, s); })();</script>"; 
        $content = $buttonCode . $content; 
        return $content; 
    } 
    add_filter('the_content', 'add_post_content'); 
    
    +0

    謝謝你的回答。我不確切地知道你的意思。請你解釋一下嗎? – racemike

    +0

    我已更新我的帖子 – dciso

    +0

    感謝您的幫助。但它不工作。 :(我不想利用你.. ^^ – racemike