根据下拉ACF选项更改选择名称
<select class="form-control search__box--btn--start" name="property_type" id="property_type">
<option value="">Property Type</option>
<?php
$args = array(
'post_type' => 'sectors',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) :
$the_query->the_post();
$title = str_replace(' ', '-', get_the_title());
$property_type_option = get_field('property_type', get_the_ID());
?>
<option value="<?php echo strtolower($title); ?>" <?php echo ($property_type == ''. strtolower($title) .'' ? 'selected' : '');?>><?php the_title(); ?></option>
<?php endwhile; ?>
<?php endif; ?>
</select>
基于“ $ property_type_option = get_field('property_type',get_the_ID());”的输出选项。我要更改“选择姓名”。
$ property_type_option = get_field('property_type',get_the_ID());输出property_type或property__sub_type
我假设我需要通过一些JavaScript来做到这一点?