I'm having a problem about showing headdings. I have added search box into my blog, but in homepage there is a text called "Latest News". It is in just homepage and archive pages. But when I search something in my search box, there is still this headding.
我有关于显示标题的问题。我在我的博客中添加了搜索框,但在主页上有一个名为“最新消息”的文本。它位于主页和存档页面中。但是当我在搜索框中搜索某些内容时,仍然有这个标题。
I use this code:
我用这个代码:
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<h5>Latest News</h5>
</b:if>
What can I do to change this text in only search pages.
如何仅在搜索页面中更改此文本。
1 个解决方案
#1
0
If you want something to appear exclusively on search results pages (/search?q={searchQuery}
) use the following code:
如果您希望某些内容专门出现在搜索结果页面上(/ search?q = {searchQuery}),请使用以下代码:
<b:if cond='data:blog.searchQuery != ""'>
<!-- Your content goes here -->
</b:if>
In addition you can retreive the search query using the <data:blog.searchQuery/> tag and display something like:
此外,您可以使用
<b:if cond='data:blog.searchQuery != ""'>
<h5>Search results for <data:blog.searchQuery/></h5>
</b:if>
Joining everything your final code snippet might be something like this:
加入你的最终代码片段的所有内容可能是这样的:
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<h5>Latest News</h5>
<b:elseif cond='data:blog.searchQuery != ""'/>
<h5>Search results for <data:blog.searchQuery/></h5>
<b:else/>
<h5>[content to display in other cases]</h5>
</b:if>
#1
0
If you want something to appear exclusively on search results pages (/search?q={searchQuery}
) use the following code:
如果您希望某些内容专门出现在搜索结果页面上(/ search?q = {searchQuery}),请使用以下代码:
<b:if cond='data:blog.searchQuery != ""'>
<!-- Your content goes here -->
</b:if>
In addition you can retreive the search query using the <data:blog.searchQuery/> tag and display something like:
此外,您可以使用
<b:if cond='data:blog.searchQuery != ""'>
<h5>Search results for <data:blog.searchQuery/></h5>
</b:if>
Joining everything your final code snippet might be something like this:
加入你的最终代码片段的所有内容可能是这样的:
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<h5>Latest News</h5>
<b:elseif cond='data:blog.searchQuery != ""'/>
<h5>Search results for <data:blog.searchQuery/></h5>
<b:else/>
<h5>[content to display in other cases]</h5>
</b:if>