Dies ist mein Code, die Standorte erzeugt:Wie Wählen Sie Wert von Javascript zu PHP weitergeben Änderung wählen Sie die Option zum Erzeugen
<select name="filter-location" id="location">
<option value="">
<?php if ($input_titles == 'placeholders') : ?>
<?php echo __('Location', 'realia'); ?>
<?php else: ?>
<?php echo __('All locations', 'realia'); ?>
<?php endif; ?>
</option>
<?php
$locations = get_terms('locations', array(
'hide_empty' => false,
'parent' => 0
));
?>
<?php if (is_array($locations)) : ?>
<?php foreach ($locations as $location) : ?>
<option value="
<?php echo esc_attr($location->term_id); ?>"
<?php if (! empty($_GET['filter-location']) && $_GET['filter-location'] == $location->term_id) : ?>selected="selected"
<?php endif; ?>>
<?php echo esc_html($location->name); ?>
</option>
<?php endforeach; ?>
<?php endif; ?>
</select>
Und dies ist der Code, die Bezirke erzeugt:
<?php $sublocations = get_terms('locations', array(
'hide_empty' => false,
'parent' => $location->term_id,
));
?>
Wie Sie sehen können, zu Bezirke generieren, benötigt es $location->term_id
.
Wie kann ich $location->term_id
senden, wenn jemand einen Standort auswählt?
Dank für die Antwort Kumpel, es funktioniert –