Note: This trick doesn't work with Labels, Archive and Followers gadgets. For these gadgets you want to use the CSS's display none method.
Let us proceed,
1. Find your widget or section Id
To address a widget or a section in HTML, you need to know its Id. Here’s how to find a widget or section Id.2. Locate the widget code in HTML
- Go to Dashboard > Design > Edit HTML.
- Check the Expand Widget Templates check box on top right of the HTML window.
- Find your widget in the HTML by using Ctrl+F and entering the widget Id in the search box.
<b:widget id='WidgetID' locked='false' title='Widget title' type='HTML'>
<b:includable id='main'>
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:includable>
</b:widget>
3. Choose the appropriate conditional tag
I listed some conditional tags in another post -Targeting specific pages with conditional tag. Copy your desired tag from there and apply it here.4. Apply the tag
Paste the tag (from step 3)
immediately after <b:includable id='main'>
and the code line 11 to 15 immediately before </b:includable>
, as shown below.<b:widget id='WidgetID' locked='false' title='Widget title' type='HTML'>
<b:includable id='main'>
PUT CONDITIONAL TAG HERE
<b:if cond='data:title != ""'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
<b:else/>
<style type='text/css'>
#WidgetID {display:none;}/*to hide empty widget box*/
</style>
</b:if>
</b:includable>
</b:widget>
Replace WidgetID
in line 13 with the widget ID from code line 1.The code will check whether the condition is true or false:
- If the result is true, it executes (and display) the widget’s content.
- If the result is false, it skips the content and hide the widget.
You need to hide the widget because in most templates the content-less widget will still appear -as an empty box.
5. Save and view
Click Save Template button and view your blog.That’s all to it. Enjoy!
original post in bloggersentral.com
How to Add meta descriptions to Blogger
0 nhận xét:
Đăng nhận xét