Blogger文章結尾的"分享"和"標籤"下方位置顯示Adsense的廣告

要在Blogge新範本主題Contempo、Soho、知名、Emporio中,每一篇文章結尾的"分享按鈕"和"標籤"下方位置顯示 Google Adsense 的廣告或其他小工具。以 Google Adsense 的廣告程式碼為例,所提供的方法如下

步驟 1、將 Google Adsense 程式碼稍做修改
 Google Adsense 給你的程式碼應該與下例相似
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 300x250 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-1234567890123456"
     data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
將第一行
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
改為
&lt;script async src=&quot;//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot;&gt;&lt;/script&gt;
若你的第一行和我的不一樣,請到http://www.elliotswan.com/postable/
將第一行的碼貼上,執行修改,便會得到修改後可讓範本讀的碼。

然後因為"分享按鈕"和"標籤"下方的這個位置,也會在首頁的每一篇文章預覽中出現,所以我們要在整個程式碼的前後各加上
<b:if cond='data:blog.pageType == &quot;item&quot;'></b:if>
讓它只在內文中顯示,不在首頁出現。
若要置中,就前後各再加上
<div style='text-align: center;'></div>
修改完後,整個程式碼應該如下
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div style='text-align: center;'>
&lt;script async src=&quot;//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot;&gt;&lt;/script&gt;
<!-- 300x250 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-1234567890123456"
     data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</b:if>
備註:有的範本上述的<div style='text-align: center;'></div>,要改成<p style='text-align: center;'></p>才行。

步驟 2、將 Google Adsense 程式碼放在範本中你想展示的位置
這裡我們想顯示 Google Adsense 廣告的位置,是在每一篇文章結尾的"分享按鈕"和"標籤"下方。所以要在範本中,搜尋關鍵字 postCommentsLink,會找到以下程式碼
<b:includable id='postCommentsLink'>…</b:includable>
點開其下一行
<b:includable id='postFooter' var='post'>…</b:includable>
</b:includable>的上一行插入剛修改後的 Google Adsense 程式碼,如下
                    <b:includable id='postFooter' var='post'>
          <div class='post-bottom'>
            <div class='post-footer float-container'>
              <b:include name='footerBylines'/>
              <b:include cond='data:widget.type == &quot;Blog&quot;' data='post' name='postFooterAuthorProfile'/>
            </div>
            <b:if cond='data:view.isSingleItem'>
                <b:include data='{ shareButtonClass: &quot;post-share-buttons-bottom invisible&quot;, overridden: true }' name='maybeAddShareButtons'/>
            <b:else/>
              <b:include data='post' name='postFooterJumpLink'/>
            </b:if>
          </div>
修改後的Adsense程式碼位置
        </b:includable>
這樣便會在文章結尾的"分享按鈕"和"標籤"下方位置下立即接著顯示 Google Adsense ,而且不在主網頁(首頁) 出現。
若是舊範本主題,如:簡單、輕柔雅緻、浮水印等,請參考這篇:
Adsense廣告自動在文章的開頭或結尾顯示
推薦網誌:宜蘭傳藝中心門票限時優惠買1送1 - 小美輕鬆旅

熱門排行

2024.2.11 friDay影音序號免費體驗

用電腦玩手機遊戲較不傷眼睛,乾淨輕量版Android模擬器推薦

置頂視窗釘選最上層顯示小工具DeskPins Win10、Win11

移除百度(Baidu)搜索,被百度綁架的解決方法

網路芳鄰電腦消失解決方法win10

不用到玉山銀行開戶,直接提領PayPal美金到台幣或外幣帳戶

免費賺比特幣7個網站推薦.錢包軟體下載及使用教學

friDay影音取消訂閱及刪除信用卡資料

2024.4.19 myVideo 序號免費體驗