Developer hooks and filters
LoopSort exposes actions and filters, all prefixed loopsort/, for adding field sources, value types and controls or adjusting the query. Values returned through filters are validated before use, so a filter can’t inject unvalidated meta keys, meta types or query arguments.
| Hook | Type | Use |
|---|---|---|
loopsort/loaded | action | LoopSort is ready (Elementor and Elementor Pro meet the minimum versions). |
loopsort/field_sources | filter | Register a field source: an object implementing Codeventure\LoopSort\Fields\Field_Source. |
loopsort/sort_types | filter | Add a value type: a label plus one of the allowed meta types (CHAR, NUMERIC, DECIMAL(10,2), SIGNED, UNSIGNED, DATE, DATETIME). |
loopsort/register_controls | action | Add your own controls to the LoopSort section. |
loopsort/query_args | filter | Adjust the query after LoopSort, with the sanitized LoopSort settings. Post status, permissions and the post type guard are re-checked afterwards. |
loopsort/raw_settings | filter | Change the settings LoopSort reads before they’re sanitized (used by Pro’s visitor sort). |
loopsort/supported_widgets | filter | Which loop widgets LoopSort modifies (only Elementor loop widgets are accepted). |
loopsort/is_pro_active | filter | Only hides the free plugin’s Pro placeholders. It never unlocks anything. |
Example: a custom field source
add_filter( 'loopsort/field_sources', function ( $sources ) {
$sources['my_fields'] = new My_Field_Source(); // implements Field_Source
return $sources;
} );
The Field_Source interface methods are id(), label(), is_available(), get_fields( $post_types ), storage_type( $key ) (text, numeric, date_ymd, datetime or timestamp) and meta_key( $key ).