Refers only to FiboSearch Pro

Expand shortcodes when indexing

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

The solution is adding the shortcode to the whitelist. It 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 name of your shorcode 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. or 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 WooCommerce -> FiboSearch -> Indexer (tab) and rebuild the index by clicking “Rebuild index”.

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