Omitting date from collection

Dear All,

I’m hosting a website with Ghost starter plan, and I collect some posts using the tag “seminars” in this page

As you can see, showing the date on the left of each seminar event creates a problem: the items are ordered by the post publication date, but that is very confusing, as the actual date of the event is another one (for the first item the post was published on the 28th of September, but the important seminar date is the 12th of October, as the post says). Clearly, I can’t set a publication date in the future, so this is an issue.

Is there a way, while staying in the starter plan, to do one of the following:

  • Display a date in the future, instead of a publication date. One could put the actual seminar date in the “Excerpt” field of the post setting, perhaps, fetch this data and display it instead of the publication date.

  • If the above doesn’t work, then show no date at all.

Thanks

You can achieve what you described by following these steps:

  1. On each seminar post, add an internal tag named #seminar-date-MONTH-DAY (e.g for 12th of October add the internal tag #seminar-date-october-12 or #seminar-date-oct-12)

  2. On the tag page, inject the following styles in “Tag Header”

<style>
    .post-feed .feed-calendar {
        visibility: hidden;
    }
</style>

  1. On the tag page, inject the following script in “Tag Footer”
<!-- Replace published date with seminar date -->
<script>
    (function() {
        const posts = document.querySelectorAll('.post-feed > .post');
        posts.forEach(p => {
            const dateElement = p.querySelector('.feed-calendar');
            const tagClass = Array.from(p.classList).find(c => c.startsWith("tag-hash-seminar-date-")) || "";
            const seminarDate = tagClass.replace("tag-hash-seminar-date-", "").replace('-', '&nbsp;');

            if (seminarDate && dateElement) {
                dateElement.innerHTML = seminarDate;
                dateElement.style.visibility = "visible";
                dateElement.style.textTransform = "uppercase";
            }
        });
    })();
</script>
2 Likes

Wow! This is amazing, thanks @Spiritix!

Yes, unfortunately your tag list will grow up, but I can’t think of any other solution that work with the starter plan.

In Ghost there are two types of tags, public and internal, internal tags always start with a hash # and are not directly accessible from your website (not visible on sitemap.xml, or RSS, or search engines …)

You can see them in the admin in the tags page (top right)
Screen Shot 2023-10-03 at 13.59.37

1 Like

This is great, thanks for all your help and explanations

1 Like