【发布时间】:2020-01-29 19:23:32
【问题描述】:
我试图从我的博客的索引页面中隐藏#old。我仍然想在搜索时看到这些帖子。
我已关注 sorrism 的 tutorial 关于如何从索引页面隐藏标签。我想知道为什么它不能正常工作?我也尝试过 Chloe 的 tutorial,但如果我在我的博客上 nowhere 显示了这个 result,最终会得到它。我在 Chloe 的教程中尝试了后者的 css 代码,但一切看起来好像没有隐藏标签。
{block:IndexPage}.hide-old {display:none;}{/block:IndexPage}</style>
<body><article class="posts hide-{TagsAsClasses}">blah blah</article><script
src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
switch(window.location.pathname) {
case "/tagged/old":
$('article').removeClass('hide-old');
break;
}
});
</script></body>
https://pastebin.com/FX1QJH5X(来自 sorrism 的教程)
.old {
display:none;
padding:10px!important;
width:450px!important;
} </style>
<body>
<div class="posts{block:IndexPage}{TagsAsClasses}{/block:IndexPage}">
https://pastebin.com/Hh3gDAaM(来自 Chloe 的教程)
【问题讨论】:
-
你能发布一个指向你的 tumblr 的链接吗?很难看到这里发生了什么。看起来您正在设置
.hide-old {display:none}和hide-{TagsAsClasses},如果它存在,它可能也会传入 hide-old,然后您的 jQuery 正在尝试删除该类名。同样<div class="posts{block:IndexPage}{TagsAsClasses}{/block:IndexPage}">将连接类名postshide-old,因为 tumblr 块之间没有空格。另外{block:indexPage}不仅仅是首页,它指的是任何索引类型的页面。 -
我的 tumblr 是 byrdy.tumblr.com。
-
我还在做一些挖掘,但在这篇文章中:byrdy.tumblr.com/post/179770158829/… 你有以下类名
posts hide-to_delete_later old reblog这意味着类hide-old永远不存在。我认为您需要一个特定的标签,并且不要使用连接方法,例如带有indexHide的帖子。我这样做的方法是将类名实际传递给主页。稍后我会发布一个链接,因为我已经写了应该更简单的答案。
标签: jquery css hide tumblr tumblr-themes