0

I've recently setup a new Wordpress install to act as a survey database. The purpose of the site is to collect survey data and allow the admin's to filter and search submitted survey data.

I've installed and configured the Algolia search WP plugin. Everything is working properly. If I navigate to 'mydomain.com/?s=' I see the search form and it's returning results.

My question is how can I set the Algolia search page as my Wordpress index/front page? Or, how can I import this form to a page that I can designate as my WP static front page?

Further info: I have a child theme installed and can create custom page templates/template-parts

1 Answers1

3

The reason is this code here...

if ( is_search() && $settings->should_override_search_with_instantsearch() ) {
        return $this->load_instantsearch_template();
    }

from this file

https://github.com/algolia/algoliasearch-wordpress/blob/1a51d3e2e8be12bfcbccd1ef2a722911a99376e7/includes/class-algolia-template-loader.php

Essentially it isn't being loaded at present where you want.

Putting this code in your functions.php will fix it.

add_action( 'wp_enqueue_scripts', function () {
        // Enqueue the instantsearch.js default styles.
        wp_enqueue_style( 'algolia-instantsearch' );
        // Ensure jQuery is loaded.
        wp_enqueue_script( 'jquery' );
        // Enqueue the instantsearch.js library.
        wp_enqueue_script( 'algolia-instantsearch' );
        // WordPress utility useful for using underscore templating.
        wp_enqueue_script( 'wp-util' );
        // Allow users to easily enqueue custom styles and scripts.
        do_action( 'algolia_instantsearch_scripts' );
    } );

Then just add the instantsearch.php code or include the file to the index page/page you want to load it on.

(I just replaced the index.php code with the code from instantsearch.php and it worked just fine)

Hope that helps.