Hide a topic list top ad from /tag/ pages?

Could anyone give me a hint on how to hide a house ad from tag pages via css? Thanks!

1 Like

Can’t test because we don’t use tags or house ads, but probably something like this in the </head> section

<script type="text/discourse-plugin" version="0.8">
  api.onPageChange((url) => {
    var isTag = /\/tag\//;
    if (isTag.test(url) == true) {
      document.getElementById("main").classList.add("tag");
    } 
    else {
        document.getElementById("main").classList.remove("tag");
    }
  });
</script>

This adds a class to your <section id="main" class="ember-application"> on all the pages with /tag/ in the url like yoursite.com/tag/tag-names so it becomes <section id="main" class="ember-application tag"> and now you can use css to hide whatever the class is that contains the ad, so something like

#main.tag ad-class-you-want-to-hide {
    display: none
}
3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.