
How to Hide or Show a Widgets in Home/Post/Static/Archive Page - By default when you add a widget on the blog then the widget will appear on the homepage and also on the pages of the other post. To create a widget only appear on certain pages or also hide certain widgets on the page corresponding we want, then we could do with adding a specific command code in template.
Hide the widget usually used on static pages that require a separate room in the blog, such as page of About, Contact, Sitemap, or other page that we want. Or maybe you just want to display a widget on the homepage only just, so that in post pages the widget is not displayed. For simplicity let us discuss one by one as follows:
Command code below inserted in an opening tag and closing tag on the widget that we want to show on a particular page.
Show elemen / widget only in Home page
<b:if cond='data:blog.url == data:blog.homepageUrl'>
...........
</b:if>
...........
</b:if>
Hide elemen / widget only in Homepage
<b:if cond='data:blog.url != data:blog.homepageUrl'>
..................
</b:if>
..................
</b:if>
Show elemen / widget only in Static page
<b:if cond='data:blog.pageType == "static_page"'>
...........
</b:if>
Hide elemen / widget only in Static page
<b:if cond='data:blog.pageType != "static_page"'>
...........
</b:if>
...........
</b:if>
Show elemen / widget only in Item page (Post)
<b:if cond='data:blog.pageType == "item"'>
...........
</b:if>
...........
</b:if>
Hide elemen / widget only in Item page (Post)
<b:if cond='data:blog.pageType != "item"'>
...........
</b:if>
...........
</b:if>
Show elemen / widget only in Archive page
<b:if cond='data:blog.pageType == "archive"'>
............
</b:if>
............
</b:if>
Hide elemen / widget only in Archive page
<b:if cond='data:blog.pageType != "archive"'>
............
</b:if>
............
</b:if>
Show elemen / widget only in URL of Specific Posting
<b:if cond='data:blog.url == "URL of Posting"'>
............
</b:if>
............
</b:if>
Hide elemen / widget only in URL of Specific Postings
<b:if cond='data:blog.url != "URL of Posting"'>
.............
</b:if>
.............
</b:if>
Note: *
- Code "==" to show
- Code "! =" To hide
Example: installation to show the element / widget only in Homepage:
<b:widget id='HTML1' locked='false' title='Nama title' 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 != ""'> <h2 class='title'><data:title/></h2> </b:if> <div class='widget-content'> <data:content/> </div> </b:if> </b:includable> </b:widget>Note:The code in red color blocks are the limits of the use the code.
The code in block color blue is the code.OR
<b:if cond='data:blog.url == data:blog.homepageUrl'> <style type='text/css'> /* -- This is a CSS style -- */ </style> <script type='text/javascript' > //This is a JavaScript code </script> </b:if> By
applying the method to show and hide the widget on a particular page above, then now you can set and put the widget to your liking. If there are any questions please scribble in the comment column.
Good luck and happy blogging!
0 comments:
Post a Comment