PHP code example of amphibee / meiliscout

1. Go to this page and download the library: Download amphibee/meiliscout library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

amphibee / meiliscout example snippets


$query = new WP_Query([
    'post_type' => 'project',
    'tax_query' => [['taxonomy' => 'project_type', 'terms' => [12]]],
    'meta_query' => [['key' => '_price', 'value' => 5000, 'compare' => '<=', 'type' => 'NUMERIC']],
    'use_meilisearch' => true,
]);

$query->meiliscout; // served or not, why, the search sent

add_action('init', function () {
    meiliscout_register_listing('projects', [
        'post_types' => ['project'],
        'route' => ['page' => 42],
        'facets' => [
            'type' => ['source' => 'taxonomy:project_type', 'path' => 'type'],
            'price' => ['source' => 'meta:_price', 'type' => 'range'],
            'year' => ['source' => 'date', 'display' => 'chips'],
        ],
    ]);
});

// In the page's template (or <x-meiliscout::listing id="projects" /> in Blade)
meiliscout_listing('projects');