Hey I'm trying to create my own custom filter for my blogs.

Expected behaviour: to filter my blog by the country field

Actual behaviour: none of my blog is published (even if the country field is filled)

Here's my custom filter Country2Filter.php:


namespace Statamic\Addons\Country2;

use Statamic\Extend\Filter;

class Country2Filter extends Filter
     * Perform filtering on a collection
     * @return \Illuminate\Support\Collection
    public function filter()
        return $this->collection->filter(function ($entry) {
            return !is_null($entry->get('country'));

The way I call my Filter in blog/list.html :

{{ collection:blog filter="country2" }}
{{ /collection:blogĀ }}

The country Field in my blog.yaml:

        max_items: "1"
          - countries
        mode: tags
        type: collection
        display: Country
        instructions: |
          If a Major is specific to a country choose one.
          If not choose none.

One Country field defined exemple:

title: 'Title'
sub_title: "Subtitle"
country: 6a44748f-4049-48aa-bc4b-8defa28a8496
hero_image: /assets/hero.png