How to Display Elements (Ads) Only On (Or Only Not At) Individual Single Post Item View

Blogger.com, a popular free blog publishing service from Google, has a extremely easy to use and convenient template system that allows users to design the blog user interface presentations by selecting a theme and then drag and drop various page elements such as poll, newsreel, video bar, feed, label, logo, AdSense, HTML/JavaScript and more to align them according to users’ preference on blog layout. However, it also comes with serious limitations, such as when you want to make certain elements (i.e. Google AdSense ad unit) to appear and show when visitors visit single post item individually, or just want to shown the widget component block on homepage, archive and label or category pages.

Blogger.com allows users to manually the XML-based template HTML, thus allows a hack which enables users to manually edit the HTML code to achieve the aim to display and show certain widgets or part of webpages on individual post page view only. However, you have need to have a basic HTML knowledge to modify the HTML code of Blogger’s template, which as editable by clicking on Template tab (or Layout of the blog you want to change if at Dashboard), and then click on Edit HTML.

The trick is show a widget in single post item view only is to add the following two lines of code to the top and bottom of the code block respectively:

<b:if cond='data:blog.pageType == "item"'>
</b:if>

The above lines will add in a condition which value is negative is the blog is not showing individual post content page. Thus anything that are wrapped inside it won’t be shown on homepage, label or category pages, or archive pages. For example, while wrapping the AdSense ads manually beside the post content, you can make the ads displayed only when individual posts are viewed by adding above 2 lines to the code, so that it will has the following structure:

<b:if cond='data:blog.pageType == "item"'>
Parsed Google AdSense Ad Code (guide to parse the HTML code of AdSense JavaScript with escape character)
</b:if>

To display the page elements or ad units on every pages except individual post content view pages, wrap the following lines of code instead:

<b:if cond='data:blog.pageType != "item"'>
</b:if>

The above statements make use of conditional statements similar to IF, ELSE, END IF in most programming languages. The Blogger XML support these three conditional statements too. Two already been used above, with the third one ELSE is <b:else>. You can make use of <b:else> to instruct Blogger template to display this widget (e.g. AdBrite ads) on all pages except single post pages, and show another widget (e.g. AdSense ads) on individual post pages.

Other than ads code or JavaScripts that are manually inserted into Blogger HTML, the above trick can be applied to widget based page elements that are added to the layout. But you need to study carefully the HTML code to identify which blocks of code is the element in order to add in above codes to wrap on top and bottom around them.

14 Responses to “How to Display Elements (Ads) Only On (Or Only Not At) Individual Single Post Item View”

  1. joe
    April 14th, 2009 06:24
    14

    Bravo!! They work first time, both wrap adsense tip and this one too. Nobody has ever explaining this as clear as easy as yours. Thanks

  2. Joharin
    January 12th, 2009 18:20
    13

    Hey there, thanks for sharing this technique. However, I’ve tried this on my blog but can’t see the correct result.

    When you say ‘item’, would that means the url for that particular post?

    Thank you for your kind help!

  3. Tarun Goel
    October 2nd, 2008 06:01
    12

    Nice Blog. I’ve gone thru your post But didn’t understand that where exactly (in Edit HTMl of Bloggers Layout) to paste the codes after parsing the HTML code of AdSense JavaScript with escape characters.

    Pls Help. I am in great need of it.

    I shall be highly obliged.

  4. HydroMan
    September 27th, 2008 11:05
    11

    Can this be done with wordpress in a similar way?

  5. izu mou
    September 27th, 2008 10:44
    10

    Thank You very mush.It is working perfectly here.

  6. Sherin
    September 7th, 2008 21:20
    9

    This is an extremely well article and whatever saying here in intact while going to real time basis. My appreciations to giving such terrific information and the well written style. Nice work.

    I have placed ad sense by following the instructions given here and it is working fantastic without a second involvement.

    Many thanks from my end.

    Sherin from Investinternals

  7. Jmay88
    August 16th, 2008 23:54
    8

    Thanks a lot..this trick is very useful to me..

  8. gre
    May 30th, 2008 02:30
    7

    this is what i looking for. thanks for help.

  9. sheetal
    May 6th, 2008 22:19
    6

    Hi,
    I like to play with html, and location of adsense on my blogs. I chanced upon your post and implemented the code to appear on a single post. Then I got a new template and I had to start all over again.So now I have bookmarked your post, for future reference. Great post.

  10. Vlada
    April 11th, 2008 01:29
    5

    I’ve tried but code is automatically set to:


    test display

    My aim is to display “test display” only on homepage.

  11. Rapidshare Bloggers
    January 13th, 2008 01:32
    4

    I used
    (if(in_category(CATID))
    {
    }

    Works great :)

  12. Sham @ Enhance Life
    January 2nd, 2008 16:45
    3

    Do u have any idea how the same thing can be done using the classic template in blogger?

    The if condition to check for?

  13. Indiaholic
    November 5th, 2007 02:20
    2

    Thanks. That helped.

  14. How to Wrap AdSense Ads Around and Inline Beside Blogger Post Content » My Digital Life
    October 3rd, 2007 01:17
    1

    [...] Note that you can also make the ads appear only on single post view. [...]

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.

New Articles

Incoming Search Terms for the Article

company advertisement using conditional statement - certain widget for label - article dashboard ads individual pages - blogger show page element depending on labels - show adsense only on single post page WordPress - show element only in homepage - conditional display - television ads including conditional statements - blogger "only on homepage" - video elements advertisement code? - blogger conditional statement - show element except on home page on blogger

Enter Email Address:

  • Translate

    Translate to EnglishPhiên dịch cho Việt Nam/VietnameseChyfieitha at Cymraeg/WelshÖversätta till Svensk/Swedishtolmačiti v slovenski/SlovenianPrevesti za Srpski/SerbianA traduce la spre Român/Romanian
    Tłumaczyć wobec Polski/Polishtagapagsalin sa Filipino/FilipinoTraducir a Latinoamericano Español/Latin American Spanishtercüme etmek -e doğru Türk/TurkishReddo ut Latin/LatinПереклад на українську/UkrainianPreložiť do slovenčiny/Slovak
    Versti į lietuvių/LithuanianTulkot uz latviešu/LatvianTerjemahkan ke Indonesia/IndonesianTradueix al català/Catalanתרגם לעברית/Hebrewहिन्दी अनुवाद करने के लिए/HindiÞýða til Íslenska/Icelandic
    Lefordít -hoz Magyar/HungarianKääntää jotta Finnish/Finnish中文翻译/Chinese Traditional中文翻译/Chinese Simplified한국어에게 번역하십시오/Korean日本語に翻訳しなさい /JapaneseTraduza ao Português/Portuguese
    Traduca ad Italiano/ItalianTraduisez au Français/FrenchTraduzca al Español/Spanishترجمة الى العربية/ArabicVertaal aan het Nederlands/DutchOversætte hen til Dansk/DanishPřeložit do Čech/Czech
    Prevesti to Hrvatski/CroatianПревеждам към Българин/BulgarianTraduzir a Língua portuguesa brasileira/Brazilian PortugueseOversetter til Norsk/NorwegianПереведите к русскому/RussianΜεταφράστε στα ελληνικά/GreekÜbersetzen Sie zum Deutsch/German
  • Categories