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>


Leave a Reply

71 Comments on "Show Widgets Only in Homepage or in Post Pages"

Notify of
avatar
Sort by:   newest | oldest | most voted
Anonymous
Guest

thank you very much

View Comment
jai ho
Guest

i tried for display widget in “All Posts”, but NOT in HomePage but all the widgets are also showing at homepage. 🙂

View Comment
Anonymous
Guest

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.

View Comment
Ammy
Guest

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

View Comment
Divya Sai
Guest

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…

View Comment
Fasil
Guest

Great tweaks to hang around for blogger’s ..

Thanks for providing this useful tricks…

View Comment
Divya Sai
Guest

Welcome Fasil !

View Comment
Fasil
Guest

Thanks a lot for providing this extra ordinary tweak…

View Comment
Swanie
Guest

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

View Comment
Divya Sai
Guest

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

View Comment
Heythem
Guest

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

View Comment
Divya Sai
Guest

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…

View Comment
Heythem
Guest

I used it and it works very well

It is very useful like your FEATURED CONTENT

TNX

View Comment
*Love*
Guest

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

View Comment
push
Guest

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 :((

View Comment
Divya Sai
Guest

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

View Comment
Soufiane
Guest

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 ;;)

View Comment
greekbox
Guest

thanks, helped me!

View Comment
ADA Image Sdn Bhd
Guest

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

View Comment
Sadr-ı Cihan
Guest

you are great.thanks

View Comment
wpDiscuz