在Blogger上我有一个<class="subheading">
我已经在项目页面上应用了所有<h2>
,但是在索引页面上,我需要<class="subheading">
作为<h3>
}。
这是我正在使用的代码,但它不起作用
代码1
<b:if cond='data:blog.pageType == "index"'>
<h3 class='subtitle' itemprop='name'></h3>
<b:else/>
<h2 class='subtitle' itemprop='name'></h2>
</b:if>
代码2
<b:if cond='data:post.body'>
<b:if cond='data:blog.pageType == "index"'>
<h3 class='subtitle' itemprop='name'></h3>
<b:else/>
<h2 class='subtitle' itemprop='name'></h2>
</b:if>
</b:if>
答案 0 :(得分:0)
请勿将您的代码放入<b:if cond='data:post.body'>
。它只会在个人帖子上执行。这应该对你有帮助。
<b:if cond='data:blog.pageType == "item"'>
<!-- Individual Post -->
<h3 class='subtitle' itemprop='name'>h3 test</h3>
<b:else/>
<!-- other pages -->
<h2 class='subtitle' itemprop='name'>h2 test</h2>
</b:if>
检查不同类型的网页和this plunker。
<强>更新强> Blogger实际上不是可自定义的,您可能需要使用jQuery调整来实现目标。根据您希望在主页和其他页面上显示的内容,可以有多种解决方案。
查看if else conditions for Blogger代码。
基本上,h2和h3中显示的文本可以保留在页面末尾的隐藏范围内。在页面加载时,您可以通过编程方式找到它,并根据您的要求在h2或h3中进行分配。另外,如果您是jQuery的新手,请查看现有博客模板中使用的代码。