隐藏索引页中的帖子

问题描述 投票:1回答:1

我正在尝试从博客的索引页中隐藏#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的教程结果)
jquery css hide tumblr tumblr-themes
1个回答
0
投票
好的,这就是我的皮肤。

将这段JavaScript添加到模板的底部。

$(document).ready(function(){ const addHTMLClass = function() { const doc = $('html'); const primaryDir = document.location.pathname.split('/')[1]; // get the first directory if(!primaryDir) { // if there is no primary directory we should be on the home page right? doc.addClass('indexPage'); // add a unique classname to the home page only } }(); });

然后是一些简单的CSS:

.indexPage .hide-old { // or add your own tag/class name here display: none; }

对于.hide-old类,您可以使用所需的任何类名,但它必须是要隐藏的帖子上的标记,但不能使用tumblr串联方法,因为这可能会传递无法预测的类名。 

我认为这可以满足您的所有需求,它并不完美,因为有些情况可能会失败,但这绝对是一个开始。

© www.soinside.com 2019 - 2024. All rights reserved.