How to pass attributes as number/integer using wp

I’m using the Wordpress plugin and passing custom post meta data to Algolia using a filter… yet the values appear to Algolia as strings and not as numbers, any advice?

This is how I pass the attribute

$attributes['ind_exp'] = get_field( 'ind_exp', $post->ID );

Thanks!

Hello,

If you want to force a value to appear as an integer you can cast it:

$attributes['ind_exp'] = (int) get_field( 'ind_exp', $post->ID );

If your attribute has decimals, you can send it like so:

$attributes['ind_exp'] = (float) get_field( 'ind_exp', $post->ID );

Let me know if that works for you!

Thanks, that solved the issue!