Change tags order based on most recent post

Hi all,

Hope you are doing well.
I’ve just started with the “Dope” Ghost Theme and it pretty much revolves around the tags. Each tag represents a tab on the home page. I’d like to make the tags change order on the home page based on which one has had the newest article posted in it. So for example, if i post under tag “BCM110”, it will move to the first place on the home page.

For reference my url is https://james-2.ghost.io and am using v.5.34.0 (it’s hosted by ghost)

I understand that i can change code in the theme and re-upload it and it will reflect the changes however I have no idea what needs to be adjusted to make this work.
Any ideas would be so greatly appreciated.

Cheers,
James

The line where the feed of tags is determined for the slider is the #get statement at line 6 of `index.hbs:

You can add a filter, etc, there, but not sure off the top of my head how to determine which tag has the most recent post.

That bit of the theme is getting all tag objects, and then by default ordering them alphabetically, not sure it even has any data regarding the date of the last post.

For reference check the List of Attributes for Tags:

1 Like

Thank you for sharing this. Appreciate it.

So if i wanted to maybe make the current alphabetical sorting of tags occur through whats in the description instead of the title? That way i could just put “A”, “B”, “C”, “D”, etc in each tag to choose which ones will appear first? Would this work?

Thanks

Actually, yeah, I think that would work.
Should be able to pass any attribute of the tag object and asc / desc to order for the #get

(this jumps to order)

Just make sure you ditch the line in the theme that outputs the description if you don’t want those A,B,Cs showing up :wink:

1 Like

Okay great!

I’m so sorry i feel really bad asking this but are you able to guide me through the process? I don’t have much experience in coding. I have my theme downloaded and can access all the theme files. Is there a certain file that i should be editing? I’m not even sure what i should be changing within the files to make this happen.

I appreciate you pointing me in the right direction regardless.

Thank you!
James

Well, you might be fine just editing those lines and rezipping the template and uploading it, but that isn’t how theme development is actually done.

If you get further into editing/customizing you can run into trouble.

You would actually do this via a local install of ghost itself, and a theme running in development mode that you then build the export (the zip file you upload, or code repository you continuously integrate).

That said, there are tons of docs and how tos out there.

Ghost’s own intro docs for dev can walk you through local install, and getting starting with theme development.

With Those Caveats
The specific change we are discussing is to the index.hbs file in the root of the theme.

/Theme folder
--- /other folder /
--- /.../
--- some file
...
--- index.hbs <-- this guy
--- other files
...

And it’s line six there {{#get "tags" limit="all"}}
That needs to become something like:

{{#get "tags" limit="all" order="description asc"}}}

And again, taking the time to get the environment setup locally to make these changes and test/verify etc., is well worth it in the long run.

1 Like