Filtering on authors attributes

Hello,
can we filter on authors objects ?
I can get all authors with {{#get "authors" limit="all"}}
I can also get a specific author with his ID {{#get "authors" limit="all" filter="id:1"}}
But now, I cannot filter on location for example such as {{#get "authors" limit="all" filter="location:internal"}}

According to the documentation there are several attributes but I do not understand how to use them in a filter.

Any idea ?

1 Like

Make sure your location name is correct which you used for the author’s location field. For example, if you want to get all the users who is from “London”, then use the following code,

{{#get "authors" limit="all" filter="location:London" }}          
{{#foreach authors}}	
<h1> {{name}}</h1>
{{/foreach}}
{{/get}}

** Filter is case sensetive

This is what I did but unfortunately it doesn’t work that’s why i’m asking to myself if all attributes are compatible with filtering!
{{#get "authors" limit="all" filter="location:test" }}

13|625x107

1 Like

Try quoting the string 'test' in your filter:

{{#get "authors" limit="all" filter="location:'test'" }}

Apparently some Ghost terms (such as slugs) can be treated as literals (not quoted), but author bio/location/social fields must be compared as strings: Filtering - Ghost Developer Docs

I’m working on a similar filter based on authors’ {{facebook}} field value (which we are hijacking to group some authors into an “occasional contributors” section) and finally figured this out, thank you for your post.

All authors whose Facebook profile field includes “occasional”:

{{#get "authors" limit="all" filter="facebook:~'occasional'" as |contributors-occasional| }}

One problem with hijacking social fields is that you may get strange-looking metadata and social previews as a result.

It might be preferable to adjust the contributor’s slug to something like oc-their-name and then filter on starting with oc.

2 Likes

True, though I can adjust the OpenGraph fields (in our case to hide them) in our theme, which I’m already editing to make this feature work.

Good idea with the slugs, though I’d like those to stay human-readable and stable (in our case an author’s status could change over time, and I don’t want their URL to change with it).