Skip Navigation

[Resolved] Algolia Search with Custom Fields

This support ticket is created 4 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Raja Mohammed 4 years, 6 months ago.

Assisted by: Raja Mohammed.

Author
Posts
#1836043

Tell us what you are trying to do? Integrate Algolia's search with Toolsets custom fields.

Is there any documentation that you are following? hidden link
https://toolset.com/forums/topic/add-toolset-custom-fields-to-algolia/

In the toolset support topic Luo Yang said that we would just need to change this:
..
$attributes['bio'] = get_field( 'bio', $post->ID );
...
to this:
...
$attributes['bio'] = get_field( 'wpcf-bio', $post->ID );
...

However, when this is used, the site produces the following error: Uncaught Error: Call to undefined function get_field
Since the function get_field is an ACF function and not a Toolset function this example will not work. Is there a similar function in Toolset to get the contents of a single field?

#1836491

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello there,

types_render_field is the function that is used to get the specific fields for each post,
The syntax would be different for each field type kindly refer to our documentation
https://toolset.com/documentation/customizing-sites-using-php/functions/

The function doesn't take any post id as it fetches the post id directly from the global on from the loop,
An example code to get a text fields would look like

types_render_field( "my-singlelinetext", array( ) ) 

The second argument usually deals with how the field should be rendered, More details are in the documentation.

In case if you are looking for an option similar to get_field to get fields based on Post_ID you can use the WordPress generic function get_post_meta with the wpcf- prefixed to the field name
eg

get_post_meta(  $post_id,  'wpcf-bio' ,  true )

I hope this helps better.

Let me know if you still need assistance.

Kind regards
Raja