Created
July 7, 2025 15:27
-
-
Save sc0ttkclark/38a773211dfc5993443cfc27f6865bd9 to your computer and use it in GitHub Desktop.
Pods - Customize the WHERE lookup for a specific pod and relationship field (for relationship lookups and more)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Customize the WHERE lookup for a specific pod and relationship field. | |
* | |
* @param array $lookup_where The WHERE conditions for the lookup keyed by column name. | |
* @param string $query The search query being used. | |
* @param string $name The name of the field. | |
* @param string $value The current value of the field. | |
* @param array|\Pods\Whatsit\Field $options The field data. | |
* @param array|\Pods\Whatsit\Pod $pod The pod data. | |
* | |
* @return array The WHERE conditions for the lookup keyed by column name. | |
*/ | |
function my_customized_where_lookup_for_pods_relationship_field( $lookup_where, $query, $name, $value, $options, $pod ) { | |
// Only lookup post_title so we will remove the post_name, post_content, and post_excerpt references. | |
if ( 'your_pod' === $pod['name'] && 'your_relationship_field_name' === $name ) { | |
unset( $lookup_where['post_name'], $lookup_where['post_content'], $lookup_where['post_excerpt'] ); | |
} | |
return $lookup_where; | |
} | |
add_filter( 'pods_form_ui_field_pick_autocomplete_lookup', 'my_customized_where_lookup_for_pods_relationship_field', 10, 6 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment