Work From Home

How To Show Content And Widgets Specific Pages And Not Others

0


Usually instances in feedback for my Blogger tutorials on this weblog, I’m requested “how do I make this work solely on posts and never pages?” or related questions referring to having widgets or scripts solely seem on sure areas of the positioning. 

As you most likely know, including a widget or HTML code to your Blogger template will normally apply that code to each web page of your weblog. A Linkwithin widget seems on the house web page, on single posts, and on pages, for instance.

There’s a option to solely make your content material seem on sure chosen sections of a Blogger template, however you want to use one thing known as Conditional Tags.

Conditional tags help you specify which elements of your template will seem underneath sure circumstances. In the event you solely need to show that Linkwithin widget or a Facebook Share button on individual post pages and never on the house web page, you are able to do that with conditional tags.  If you wish to conceal sure parts of your design on sure pages, you are able to do that as nicely.

Earlier than leaping into this, word that this method is a little more superior. If in case you have hassle understanding HTML it would be best to watch out when modifying your template with code. You’ll be able to strive enjoying round with these choices on a check weblog till you are feeling comfy implementing them into your individual.

Blogger has a bunch of conditional tags you should use to focus on particular pages. Here’s a listing of them under:

Blogger Conditional Tags

Index Pages
Consists of: house web page, label pages, and yearly archive pages

<b:if cond='information:weblog.pageType == "index"'>
YOUR CODE HERE. IF THIS IS THE INDEX PAGE, DO THIS.
</b:if>

Residence Web page
Consists of: the house web page solely

<b:if cond='information:weblog.url == information:weblog.homepageUrl'>
YOUR CODE HERE. IF THIS IS THE HOME PAGE, DO THIS.
</b:if>

Merchandise Pages
Consists of: single posts (i.e. if you open up a single submit to learn)

<b:if cond='information:weblog.pageType == "merchandise"'>
YOUR CODE HERE. IF THIS IS AN ITEM PAGE, DO THIS.
</b:if>

Static Pages
Consists of: pages created in the Pages section of Blogger (not posts)

<b:if cond='information:weblog.pageType == "static_page"'>
YOUR CODE HERE. IF THIS IS A STATIC PAGE, DO THIS.
</b:if>

Archive Pages
Consists of: posts in your archive, older/newer posts pages

<b:if cond='information:weblog.pageType == "archive"'>
YOUR CODE HERE. IF THIS IS AN ARCHIVE PAGE, DO THIS.
</b:if>

Search/Label Pages
Consists of: pages which might be accessed by way of the label cloud or listing and in your submit footer

<b:if cond='information:weblog.searchLabel'>
YOUR CODE HERE. IF THIS IS A LABEL PAGE, DO THIS.
</b:if>

Search Question Pages
Consists of: pages which might be accessed utilizing the Search widget operate

<b:if cond='information:weblog.searchQuery'>
YOUR CODE HERE. IF THIS IS A SEARCH RESULT PAGE, DO THIS.
</b:if>

Error Web page
Consists of: your error web page when a submit isn’t discovered or doesn’t exist

<b:if cond='information:weblog.pageType == "error_page"'>
YOUR CODE HERE. IF THIS IS THE ERROR PAGE, DO THIS.
</b:if>

Particular Web page/URL
Consists of: a selected web page that you simply provide. Enter your URL within the code under

<b:if cond='information:weblog.url == "URL"'>
YOUR CODE HERE. IF THIS IS THE PAGE SPECIFIED, DO THIS.
</b:if>

First Publish
Consists of: solely the primary submit proven in your weblog. Doesn’t embrace pages.

<b:if cond='information:submit.isFirstPost'>
YOUR CODE HERE. IF THIS IS THE FIRST POST, DO THIS.
</b:if>

The best way to use these

These codes can be utilized anyplace inside your template’s HTML web page, excluding inside a <b:part> or <b:widget> tag. In the event you solely desire a Linkwithin widget to look on particular person submit pages, for instance, you’d use this code within the place you need your Linkwithin widget to look in your template (normally within the submit footer)

<div class='post-footer-line post-footer-line-2'>
<b:if cond='information:weblog.pageType == "merchandise"'>
<div class="linkwithin_div"></div>
</b:if>
</div>

All you want to do is put the content material between the conditional tags as proven above.

Reversing a Situation

If you wish to exclude a web page or submit, you would possibly need to reverse a situation. Which means the content material you specify will solely seem on pages aside from the one you’ve included within the tag. You’d merely implement a reverse situation like so:

<b:if cond='information:weblog.pageType != "static_page"'>
YOUR CODE HERE. IF THIS IS NOT A STATIC PAGE, DO THIS.
</b:if>

All we did was change the == to != within the code above. As an alternative of claiming “if this web page is the same as the merchandise” now we have modified it to “if this web page isn’t equal to the merchandise”.

This will likely appear complicated at first, however when you get the dangle of it, these conditional tags could be extraordinarily helpful!



Source link

Leave A Reply

Your email address will not be published.