Filters /

Implementation Methods

Ajax Load More Filters can be implemented on the frontend via shortcode or the alm_filters PHP function.

Shortcode

The shortcode render method can be used to insert a shortcode in the code editor or a theme template.

// Template (.php)
echo do_shortcode( '[ajax_load_more_filters id="my_post_filter" target="YOUR_ALM_ID"]' );

// Block Editor
[ajax_load_more_filters id="my_post_filter" target="YOUR_ALM_ID"]
JavaScript

alm_filters (PHP Function)

The alm_filters() method must be implemented via page template (php) or backend functions file.

$filter_array = array(
    "id" =>  "my_post_filter",
    "filters" =>  array(
        array(
            "key" =>  "taxonomy",
            "field_type" =>  "checkbox",
            "taxonomy" =>  "category",
            "taxonomy_operator" =>  "IN",
            "taxonomy_include_children" =>  "false",
            "title" =>  "Categories",
        )
    )
);  
echo alm_filters( $filter_array, 'YOUR_ALM_ID' );
PHP

When passing an array of data to the alm_filters() function, it’s important that you do NOT delete the filter from the WordPress backend as it is still required for various frontend functionality.

The alm_filters() method can also accept a reference to a Filter ID in place of the data array.

echo alm_filters( 'my_post_filter', 'YOUR_ALM_ID' );
PHP

Note: Don’t forget to replace YOUR_ALM_ID in the samples above with your Ajax Load More ID.


« Back to Filters