Adding big number of custom fields to wpfts_index_post hook. API docs.
-
Hello!
In docs https://fulltextsearch.org/documentation/#item4_2
there is the following example code:/** * This snippet adds metadata of "employee" post to search index */ add_filter('wpfts_index_post', function($index, $post) { global $wpdb; // Basic tokens /* * This piece of code was commented out intentionally to display things * which was already done before in the caller code $index['post_title'] = $post->post_title; $index['post_content'] = strip_tags($post->post_content); */ if ($post->post_type == 'employee') { // Adding new token "employee_data" specially for posts of type "employee" $data = array(); $data[] = get_post_meta($post->ID, 'address', true); $data[] = get_post_meta($post->ID, 'phone', true); $data[] = get_post_meta($post->ID, 'name', true); $data[] = get_post_meta($post->ID, 'function', true); $index['employee_data'] = implode(' ', $data); } return $index; }, 3, 2);Why we need global $wpdb here?
On our website we have many acf field groups connected to gutenberg blocks(up to 100 field groups). It is very inconvinient to add them manually by code. Can you please advise any other variant of adding big number of fields?
One more question: where I can find docs for plugin API?
Thank you!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
The topic ‘Adding big number of custom fields to wpfts_index_post hook. API docs.’ is closed to new replies.