December 2, 2008

Show Widgets Only in Homepage or in Post Pages


Once you activate any widget, in your blog, it will be displayed in all the pages by default, including your homepage.
But sometimes, we do want to show some widgets only on Homepage or only for the individual posts pages, or only in a specific page, the coding is quite simple, but you need to customize the widget through the "Edit HTML" link in your "Layout" section.

Follow these steps:
Create any widget, and place it where-ever you want, and save the template. Check if it is working (should be displayed in all the pages). Remember to give a TITLE to it, like Archives/BlogRoll/Maps/Clock, anything unique.


Now go to "Edit HTML" page.
Click/mark "Expand Widget Templates"
Then find for that unique Title (by searching through CTRL+F method)
It will be something like this:
<b:widget id='HTML3' locked='false' title='UNIQUE WORD OR TITLE HERE' type='HTML'>
<b:includable id='main'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>

<b:include name='quickedit'/>
</b:includable>
</b:widget>

Now tweak this as follows

CASE #1
To SHOW the code/widget only in HomePage
<b:widget id='HTML3' locked='false' title='UNIQUE WORD OR TITLE HERE' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>

<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>

CASE #2
To SHOW the widget in "All Posts", but NOT in HomePage
<b:widget id='HTML3' locked='false' title='UNIQUE WORD OR TITLE HERE' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "item"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>

<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>

CASE #3
To SHOW the widget in any particular page
<b:widget id='HTML3' locked='false' title='UNIQUE WORD OR TITLE HERE' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == "SPECIFIC_BLOG_POST_URL"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>

<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>
Add those code lines in red color, as per your requirement.

CASE #4
To HIDE a widget ONLY in a particular page/post, and to display it in all other pages of your blog, use this code (shown below is only the code in RED from the previous code):
...
...
<b:if cond='data:blog.url != "SPECIFIC_BLOG_POST_URL"'>
...
...
...
</b:if>
...
...

CASE #5
To SHOW widgets only in Archive Pages
...
...
<b:if cond='data:blog.pageType == "archive"'>
...
...
...
</b:if>
...
...

CASE #5
To SHOW widgets only in Static Pages
...
...
<b:if cond='data:blog.pageType == "static_page"'>
...
...
...
</b:if>
...
...

CASE #6
To HIDE widgets in Static Pages
...
...
<b:if cond='data:blog.pageType != "static_page"'>
...
...
...
</b:if>
...
...


73 comments:

Anonymous said...

thank you very much

jai ho said...

i tried for display widget in "All Posts", but NOT in HomePage but all the widgets are also showing at homepage. :)

Anonymous said...

I implemented it to show a widget only on homepage in the crosscol section of my testblog and it works great.
Thank you very much. This is just what I'm looking for.

Ammy said...

:)) The second Version is not working. . guess to show on all page except homepage

Divya Sai said...

Well dude, I have myself used all these hacks, and they have worked well in my blogs, make sure all the code work is in correct place...

Fasil said...

Great tweaks to hang around for blogger's ..

Thanks for providing this useful tricks...

Divya Sai said...

Welcome Fasil !

Fasil said...

Thanks a lot for providing this extra ordinary tweak...

Swanie said...

Thanks for the tips. Hi all, please remember to replace " with "&

Divya Sai said...

Hi Swanie, about which of the 3 hacks are you talking about ?

Heythem said...

Tnx again Divya Sai

I have a question, Does Widget(Contain Text Only) Slows your loading time of blog?

If yes
{
What if I used only "To display widget in any specific page"

Does it slows my HOMEPAGE? or the only specific pages I choose?
}

If No
{
Can I Spam it? assuming text are easy to load

Your HTML cannot be accepted: Tag is not allowed

so I will use c language

like this

if(data:blog.url == "blog.com/title1)
{
Text:title 1
}

if(data:blog.url == "blog.com/title1)
{
Text:title 1
}

}
I hope you will answer my questions. tnx

Divya Sai said...

If you are considering only text/simple HTML widgets, then you need not have to worry about SEO/loading time as text is very light & easy to load, but if there are pictures/videos or javascript etc., in the widget, then it will of course delay the loading time.

Now if you use widgets to display only in certain pages(eg. homepage), then it will not slowdown your other pages...

Heythem said...

I used it and it works very well

It is very useful like your FEATURED CONTENT

TNX

*Love* said...

i want to hide the social bookmarks from the homepage but i have done the coding in the html layout now what's the UNIQUE WORD OR TITLE of it..
how can i hide them without knowing its title

push said...

i want to hide the social bookmarks from the homepage but i have done the coding in the html layout now what's the UNIQUE WORD OR TITLE of it..
how can i hide them without knowing its title :((

Divya Sai said...

You do not need the unique word now, simply add the code for bookmark buttons between the code required to hide them from the homepage,
Read this comment:
Read More

And for the social bookmarking buttons code, you may read this post:
Social Bookmarking Buttons

Soufiane said...

it works as a charm !
i search &alt;b:widget id then i add the codes in red and it works. the widgets are only shown in pages i wants, but there is a very small rectangle in their place.

another 100% working hack, thanks divya :|

i give a name to every widget in order to find in in the HTML code, then i erase the names and let it blanc ;;)

greekbox said...

thanks, helped me!

ADA Image Sdn Bhd said...

hi.thnx a lot for the info.but i want to know, what if i want the widget in certain FEWS pages.
example, i just want to be only in 10 selected pages.

Thank you

Sadr-ı Cihan said...

you are great.thanks

Khmer Spy said...

It sure worked, but my main content doesn't resize. Please help: http://kh-spy.blogspot.com/2009/11/spy-another-test-for-article-submission.html

Leslie Ann said...

thank you. i was trying to figure this out on my blog and your post pretty much solved it for me.

MST-INFO said...

how can i put a widget only in label page .??

Divya Sai said...

Instead of this "SPECIFIC_BLOG_POST_URL" use the specific url of a label.

कांचन कराई said...

Before I try this on my blog, I would like to know, how can I use this widget for multiple labels. I want to show specific header for specific label. I have at least 4 to 6 labels. Can I use the above widget and how?

कांचन कराई said...

It not happening with my blog. :(

Divya Sai said...

Hi Kanchan, plz mail me all your 6 header images along with the lable urls (to this address bloggerstop.net@gmail.com)

कांचन कराई said...

Okay. I will do it. Thanks a lot!!

कांचन कराई said...

I've mailed you all my blog headers and label links. Thank you.

कांचन कराई said...

Is there any way we can have 'Reply' comment option, like Wordpress - "individual comment reply option"?

Sai @ Blogger Help said...

Yeah I got your mail Kanchan, I'll reply to it soon.
BTW yes you can have those reply buttons and many more additional fuctions, read this post:
http://bloggerstop.net/2009/07/add-intensedebate-disqus-and-js-kit-to.html

कांचन कराई said...

You are an angel :-*

Divya Sai said...

:)

Bikin said...

I tried putting this on a certain page and it didnt work, there are more lines in my layout then yours, would that cause an issue? Can I email you mine too?? That would be awesome.

Divya Sai said...

Yes you may email me your template ans also plz mention exactly what is your requirement, like mention the widget (with title) that you want to display only in the homepage or in the posts pages.

B Donald said...

This is a nice feature to add, I assume the URL that's displayed when I am viewing my new page is the URL thats added in place of SPECIFIC_BLOG_POST_URL
Also I had to add "/" to properly close the code but the forum is till showing up on the main page as well as the forum page.
Any idea's?
Thanks, Brett

Divya Sai said...

Hey Brett,

No, that Slash "/" is not required.
Slash "/" is used only after .com/ or .net/
but never after .html/ or .php/

Remove that slash, and your forum will stop displaying in your homepage.

Darius said...

I found this advice on many other sites but never managed to pull it off without this nice and simple guide how to do it.

Many thanks and this post made me add your site to my Bookmark list :-)

Sai - BloggerStop.Net said...

I am glad it helped you Darius...

harfehesaab said...

Hi
Seeing how you make things look easy I am tempted to ask you to help me please with 3 problems that I have.
1. How can I make posts with a particular label appear in a static page.
2. How can I force blogger to show only three or four labels and not more although I want to use a lot more.
3. How can I make a post page free from side bars. I want the side bars for home page but not for post pages.

I will be looking forward to hearing from you.

Millions of thanks.

harfehesaab said...

I will wait to get you help and advice. Thanks.

Morph said...

hi just spent an hour sorting all my widgets out great all ok and easy but- i have a small problem, i cant seem to be able to show the adsense and archive and also other post only on the homepage, every time i try to put in the extra codes i get a html script issue when i try and save the template
you can see what i mean
http://white-owl-conspiracy.blogspot.com/

what do you suggest?
cheers

loulou said...

Thanks so much for this...I think it will had some sparkle to my new blog!! :-)

Mr. O said...

Amazing just followed everything form the forum creation to this and it looks sick on my blog

http://buyingairyeezys.blogspot.com/p/nike-air-yeezy-forum.html


Thanks ever so much now all I need is to create the next and previous tabs that you have on this page and ill be soooooo happy.

Thanks ever so much for this

Regards

Harvey44 said...

This does seem to be working for me. I have a ton of widgets to get through and exclude from my forum page. I just did the first one and it LOOKS like I excluded it, but that the sidebar WRAPPER is still there. Is there a fix for that?

Thank you.

Harvey44 said...

One more point ... it SEEMS like the widget for the main post is quite different and I couldn't figure out how to exclude that from the forum page.

While the Adsense widgets look different (simpler) in expanded form it looks like the exclusion there is pretty straightforward.

If I can get all these widgets excluded and the wrappers too this will be great. Thank you very much.

Sanskar Shrivastava said...

I just embedded a forum on my blog by following a tutorial on your website. As you described i did the same and then made the widget available only in the specific page, the forum is working perfect but below this i see my sidebars, other gadgets. etc. I don't want them as it is in your forum, how to do that?

here is the link http://enewsreport.blogspot.com/p/world-today-forum.html#/

Harvey44 said...

This was an AWESOME POST that allowed me to start a forum. (It's not open to the public yet but it looks really great IMO).

I solved the sidebar issue with help from the Blogger forum. You need some conditional code. It took me a WEEK to figure out so buddy you scored!

My only problem is I don't know how to post code in a comment. I will try:

Right under this:

]]>

Put this:

[b:if cond='data:blog.url== "YOUR_FORUM_URL_HERE"']
[style]
#main-wrap1,
#left-sidebar-wrap,
#sidebar-wrap,
.NewTopSidebar {display:none;}
#main-wrap{display:none}
[/style]
[/b:if]

Everywhere I used [ use the carrot "<" and use ">" instead of ]

Also I found that my main wrapper is call "wrap" not "wrapper" so make sure you sidebar and main wrap names are correct.


My forum is here:

http://www.nyskiblog.com/p/harvey-road-forum.html

no sidebars!

MANY thanks to BloggerStop.net!

Divya Sai said...

Hey Harvey,

Glad to know that your forum is now looking exactly as you want. Due to my busy schedule couldn't reply to comments on my blog - so sorry for that.
Anyways, I will try to answer the pending queries of this post now...

Divya Sai said...

@Sanskar,
In your template, fiond this code:

</head>

And IMMEDIATELY above/before it, paste this code:

<b:if cond='data:blog.url == &quot;http://enewsreport.blogspot.com/p/world-today-forum.html&quot;'>
<style type='text/css'>
#outer-wrapper {
display:none !important;
}
</style>
</b:if>

Sanskar Shrivastava said...

Oh yeah!! Thanks it worked!! Do you have a tutorial to add facebook connect also? I tried their developers video, and janrain application both are not working for me, I dont want disqus coz their comments will not be crawled by google and js kit doesn't look free

Divya Sai said...

I hope this tutorial will help you:
Add Facebook Buttons and Widgets To Your Blog

And thanks for informing about js-kit (echo), as I didn't know that it went completely premium now.
In that case, the options left with you are disqus and IntenseDebate, but not sure if they have done something for SEO recently or not.

nazifa said...

hi...I put read more widget in my blog..unfortunately the read more also function at pages. I don't want read more show at pages...help me plzz

Divya Sai said...

Which method do you use to truncate your posts?
and how many posts do you have on your blog, where you ar eusing this read more hack?

nazifa said...

actually I'm still not using the tutorial above bcoz i'm not understand...I have 23 post in my blog..and 1 have 6 pages that I put on menu bar...however the pages also have readmore button and when click, it does not show details post.

Divya Sai said...

Okay 23 posts in not a big number. You can easily remove that read more button from your static pages, just tell me which method/code do you use to truncate the posts (is it <!-- more --> or this one <span class="fullpost"> or is it an automatic truncating script).

nazifa said...

hi..below is my read more scropt

<b:if cond='data:blog.pageType != &quot;item&quot;'>

<div expr:id='&quot;summary&quot; + data:post.id'><data:post.body/></div>
<script type='text/javascript'>createSummaryAndThumbundefined&quot;summary<data:post.id/>&quot;);</script>
<span class='rmlink' style='float:right;padding-top:20px;'><a expr:href='data:post.url'> Read full story</a></span>

</b:if>
<b:if cond='data:blog.pageType == &quot;item&quot;'><data:post.body/></b:if>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>


how to change the script...I only want the read more only show in homepage only and not include static page

java said...
This comment has been removed by the author.
java said...

My template was a different one .how can i add this widget only for my home page

Admin - BloggerStop.Net said...

Which widget? Be it any template, use the code from CASE #1.

bumblyberry said...

FINALLY!!!!! I have been searching and searching for a way to only have by widgets on my home page. This is the ONLY post I have found that tells you to go in AND NAME your widget w/a unique title so you can find exactly where to place your html fix. Perfect solution, I am so happy to finally have this worked out.

Sai - Blogger Help said...

:)

tech guru said...

AH!
Hello admin,
Is this trick for Blogger or Wordpress?

I dont think we have these codes in wordpress.
CAn you please help me to show some widjets only in Homepage of wordpress?

thecleanbug said...

THANK YOU! I've been trying to figure out all day how to get my widget to only appear on my homepage. Yours was the first one that worked! thank you thank you :)

mr smooth said...

i cant make it work for adsense!

Info Geek said...

thanks a lot

Saif said...

Thanks a lot for this post. I loved it :)

admin said...
This comment has been removed by the author.
admin said...

This post Are Very Useful for my Blog

www.taporifun.com!

Constantin said...

Awesome, man!

Thank you so much for this!

Analyst said...

How to control slider movement which is showing favourite posts. Say we want to block on X page and slider code is embedded in template. It will be great if you can amplify. Your above post works very well for widgets. Rgds

Christian Abalo said...

On the Case 3


what if i have more than 1 URL?

Harvey44 said...

Clicking on the unsubscribe link leads me here.

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

comment on this post Share Your Views

Allowed HTML tags: <b>, <i> and <a>

Join and share your views with other bloggers at BloggerStop Community

Comment Like This! and Optimize your blog...

SPAMMER OF THE MONTH: www[.]TopRankLinks[.]com

Next Post Homepage Previous Post

Regular Readers


What They Say...

Divya Sai is the ingenious webmaster of Bloggerstop.Net. Divya is extremely patient, knowledgeable and responsive... Bloggerstop.net has an abundance of articles on creating widgets, templates, hacks and ways to make your blog search engine friendly.
- Stacey @Pets With Allergies
I stumbled onto a great site. Sai, over at Bloggerstop.net has helped me tremendously and with great patience...for any and all questions regarding computer issues. And again, THANK YOU Sai.
- Cheryl @Cmash Loves To Read

More Here...

Popular Posts

Get this widget

| © 2010 BloggerStop.net | Blogger Widgets | Template by Dicas Blogger | Enhanced By Divya Sai | Privacy Policy