In tumblr, show only posts with a certain tag in the home page

后端 未结 8 556
忘掉有多难
忘掉有多难 2021-01-03 03:56

In tumblr, is it possible to show only posts with a certain tag in the home page?
If so, how is it done?

8条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-03 04:10

    Using mircealungu's suggestion worked perfectly for me! Here's how I did it:

    1. Find the article tag, and add the classname:

    class="notfeatured {TagsAsClasses}"

    If it already has a classname, add the part in bold above inside the classname quotes. Mine ended up looking like this:

    2. Find the div tag that precedes the article tag, and add the classname:

    class="{block:TagPage} tag_page {/block:TagPage}{block:PermalinkPage}perma_page{/block:PermalinkPage}"

    Again, if a class already exists, just add the part in bold above inside the classname quotes. Mine ended up like this:

    3. Finally, add this to your CSS:

    article.notfeatured {display: none;}
    article.featured, .tag_page article.notfeatured, .perma_page article.notfeatured {display: block;}
    

    Now any post tagged as "featured" will display on your home page, but nothing else. So far no issues for me, it works great! You can see it here.

    You can also use javascript to reorder the display so you can make the featured posts appear first in a list. The script is very simple:

    $('article.featured').prependTo('#posts');
    

    And here is a demo. Just place that inside javascript tags and put it right before the /body tag in your theme. In this case don't use the CSS above, because you don't want to hide the posts. I implemented a .top class for the script and kept the .featured class for the CSS, and I use both the CSS and the script.

提交回复
热议问题