Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Epsiloncool

    (@epsiloncool)

    Sure, it’s simple.

    Since we have no good UI for this, you can add a small code:

    
    add_filter('wpfts_index_post', function($index, $post)
    {
        global $wpfts_core;
    
        if ($post && $wpfts_core) {
            // Example for ACF fields
            // 1. Check if the post has correct post_type
            if ($post->post_type == 'my_post_type2') { // Use YOURS here
                 // 2. Check if ACF is active!
                 if (function_exists('get_field')) {
                     // 3. Get ACF field value
                     $t = get_field('my_acf_field', $post->ID); // Use YOURS here
                     // 4. Store to index
                     $index['my_cluster2'] = trim($t); // YOUR cluster name
                     // Repeat 3 & 4 if you need to index more ACF fields
                 }
            }
         }
     
         // Return summarized $index to put it to database
         return $index;
    }, 3, 2);
    

    Put this code to your functions.php of the child theme and rebuild index.

    You can use Sandbox Area Tester to test the wpfts_index_post hook without need to rebuild index just to be sure everything is indexed.

    Hope this helps.

    Thanks for the question.

    Thread Starter joelrhd

    (@joelrhd)

    This is so cool thanks! Just another?question..what if I upload the document/pdf inside ACF File field. Will it still?search inside that field?

    Plugin Author Epsiloncool

    (@epsiloncool)

    Yes, it will, however for search inside the files you will need the pro version.
    You can get one for free here https://fulltextsearch.org/evaluation/

    The respective code will be:

    
    // 2. Get the url of the attached file (set "url" in the ACF field settings)
    $url = get_field('my_attached_file', $post->ID);
    if (strlen($url) > 0) {
        // 3. Include WPFTS's Pro library
        require_once $wpfts_core->root_dir.'/includes/wpfts_utils.class.php';
    
        // 4. Extract file content
        $ret = WPFTS_Utils::GetCachedFileContent_ByLocalLink($url);
    
        // 5. Store to index
        $index['my_cluster3'] = isset($ret['post_content']) ? trim($ret['post_content']) : '';
    }
    

    This code should be inserted after the “// Repeat 3 & 4 if you need to index more ACF fields” line of the previous snippet.

    Hope this helps!

    Thread Starter joelrhd

    (@joelrhd)

    Thank you so much it works ?? We will get the pro version indeed

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can I search inside custom fields generated from ACF plugin?’ is closed to new replies.