假设您的“property guests”分类有“1”、“2”、“3”等名称:
<?php
// Get the number of guests the visitor searched for
$requiredGuests = $_POST[\'guests\'];
// Get all terms in the "property-guests" taxonomy
// (By default, this will only include terms that are assigned to something)
$allGuestNumbers = get_terms(array(\'taxonomy\' => \'property-guests\'));
// Create a variable to use in the args later
$queryNumbers = \'\';
// Determine which properties have enough room for the number of guests requested
foreach($allGuestNumbers as $guestNumber) {
// Check if the number is greater than or equal to the number requested
if($guestNumber->name >= $requiredGuests) {
// If so, add to the variable for args, with a comma to separate the numbers
$queryNumbers .= $guestNumber->name . \',\';
}
}
// Now, use the variable in the args
$guests_tax_array = array(
\'taxonomy\' => \'property-guests\',
\'field\' => \'term_id\',
\'terms\' => $queryNumbers,
\'compare\' => \'IN\'
);
?>
如果您的“属性来宾”分类法没有数字作为其名称,您可以使用其slug,或名称或slug的子字符串-这取决于您如何设置各个术语。