Get WPFTS Pro today with 25% discount!

Include PDF's Uploaded via RCWD Upload

  • I currently use RCWD for ACF to upload attachments, but since I have thousands of PDF's i didn't wont to clutter up the media library. Is there a way to still use the search feature when using this plug. Here is a link to it for your reference:

  • Hi @loyolalax10

    Yes, this could be done with the help of a small PHP snippet which should be added to your website (or custom add-on plugin). I am ready to develop this small snippet for you for free, but I will need a copy of RCWD (without a license) to develop the code. May you please provide it?

  • Hi, the idea is to use wpfts_index_post hook to extract the special meta-field (added by RCWD) value and index the file which is linked there.

    The working code is below.

    add_filter('wpfts_index_post', function($index, $post)
    	global $wpfts_core;
    	if ($post && $wpfts_core && function_exists('get_field')) {
    		if ($post->post_type == 'paper') {		// You can change the post_type here
    			$file = get_field('file', $post->ID);	// You can change the ACF field name here
    			if (isset($file['path']) && (strlen($file['path']) > 0)) {
    				// Add a special library to work with file contents (included to WPFTS Pro)
    				require_once $wpfts_core->root_dir.'/includes/wpfts_utils.class.php';
    				// This call will return extracted text from the FILE
    				$ret = WPFTS_Utils::GetCachedFileContent_ByLocalLink($file['path'], false, true);
    				// Store the content to separate index cluster (so we can apply different relevance weight to it, if required)
    				$index['rcwd_file_content'] = isset($ret['post_content']) ? trim($ret['post_content']) : '';
    	return $index;
    }, 3, 2);

    Looks not that hard?

    Also, you can download the ready addon plugin here.