<?php
// Allow FacetWP to detect Salient's Visual Composer Post Loop Builder
// Needs the 'facetwp-template' class set on the Post Loop Builder element: https://d.pr/i/x4j75G
// Disable the element's own (Load more) pagination: https://d.pr/i/4ZumQ0
// Use a Pager facet instead (numbered or load more type).
add_filter( 'nectar_post_grid_query', function( $query_args ) {
$post_types = ['resource', 'post']; // Run only for Post Loop Builder grids with these post types
if ( in_array( $query_args['post_type'], $post_types ) ) {
// Detect Post Loop Grid query
$query_args['facetwp'] = true;
// Fix pagination
if ( array_key_exists('offset', $query_args ) ) {
unset( $query_args['offset'] );
}
}
return $query_args;
}, 10 );