-
-
Save sc0ttkclark/8fece91df8064663af54ae8f53a88f7b to your computer and use it in GitHub Desktop.
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 | |
//pods: https://imgur.com/a/MflzgtI | |
$search = sanitize_text_field( $search ); | |
$query = array(); | |
$query[] = 'brand.meta_value = ' . absint( $_REQUEST['brand_id'] ); | |
$query[] = ' | |
d.asset_name LIKE "%' . pods_sanitize_like( $search ) . '%" | |
OR product_d.sku like "%' . pods_sanitize_like( $search ) . '%" | |
'; | |
//$query[] = " d.asset_name LIKE \"%".$search."%\" or sku.post_title like \"%".$search."%\" "; | |
//$query[] = " d.asset_name LIKE \"%".$search."%\" or sku.id like \"%".$search."%\" "; | |
$params = array( | |
// This will make sure it joins Product relationship data we need to know. | |
'select' => '`t`.*, `d`.*, `prod`.`ID`', | |
// Join the product data table so we can reference it. | |
'join' => 'LEFT JOIN `wp_pods_product` AS `product_d` ON `product_d`.`id` = `prod`.`ID`', | |
'limit' => 8, | |
'orderby' => 'date DESC', | |
'where' => '( ' . implode( ' ) AND ( ', $query) . ' )', | |
); | |
// Run the find | |
$mypod = pods( 'asset', $params ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment