Refers to FiboSearch Pro only

Expand shortcodes when indexing

In FiboSearch Pro, shortcodes are ignored in the indexing process. This means, for example, if you have  an accordion shortcode in a product description, you will not be able to search for keywords contained in this accordion.

The solution is to add the shortcode to the whitelist. This works for FiboSearch Pro v1.13 or higher. Here is how you can do it. Suppose you use the following shortcode in your product description:

[lightweight-accordion title="Sample title"]
Sample content
[/lightweight-accordion]

You have to apply the following snippet that adds the name of your shortcode to the whitelist.

add_filter( 'dgwt/wcas/indexer/allowed_shortcodes', function ( $shortcodes ) {
    $shortcodes[] = 'lightweight-accordion';

    return $shortcodes;
} );

You have two ways to add this code to your theme:

  1. Open the functions.php in your Child Theme and add the code at the end
  2. Install the Code Snippets plugin and apply this code as a snippet

Expand TablePress shortcodes

TablePress requires a different approach. To search in TablePress contents, you’ll need to use the following snippet:

// Allow [table] shortcode indexing
add_filter( 'dgwt/wcas/indexer/allowed_shortcodes', function ( $shortcodes ) {
   $shortcodes[] = 'table';

   return $shortcodes;
} );

// Init TablePress shortcodes
function fibosearch_init_tablepress_shortcodes() {
   if ( defined( 'TABLEPRESS_ABSPATH' ) ) {
      if ( ! isset( TablePress::$model_options ) ) {
         include_once TABLEPRESS_ABSPATH . 'classes/class-model.php';
         include_once TABLEPRESS_ABSPATH . 'models/model-options.php';
         TablePress::$model_options = new TablePress_Options_Model();
      }
      $tablepress_controller = TablePress::load_controller( 'frontend' );
      $tablepress_controller->init_shortcodes();
   }
}

// Init TablePress before batch indexing
add_action( 'dgwt/wcas/searchable_index/bg_processing/before_task', function () {
   fibosearch_init_tablepress_shortcodes();
} );

// Init TablePress while single product update
add_action( 'dgwt/wcas/tnt/background_product_update', function ( $action, $postID ) {
   if ( $action !== 'update' ) {
      return;
   }
   fibosearch_init_tablepress_shortcodes();
}, 5, 2 );

Open the functions.php in your Child Theme and add the code at the end or use the Code Snippets plugin. After that, go to WooCommerceFiboSearchIndexer (tab) and rebuild the index by clicking “Rebuild index”

If you change a table, you’ll need to rebuild the index.