Algolia - WordPress - Instantsearch menu for Custom Post Type

248 Views Asked by At

I would like to get instantsearch widget to filter Custom Post Types. So this menu filter: https://community.algolia.com/instantsearch.js/documentation/#menu only to filter Custom Post types.

I have tried it so:

                search.addWidget(
                  instantsearch.widgets.menu({
                    container: '#post-type',
                    attributeName: 'post_type',
                    limit: 10,
                    templates: {
                      header: 'Post Types'
                    }
                  })
                );

And of course div to render the code:

<div id="post-type"></div>

It renders the title correctly and all is working but the Custom Post Types won't get listed at all in any shape or form.

Is it even possible to render CPT this way?

Any advise appreciated.

1

There are 1 best solutions below

1
On

All that needs to happen for this to work is changing the attribute name to: 'post_type_label'