【发布时间】:2018-01-09 23:01:21
【问题描述】:
我正在寻找一种方法来保留从 WordPress 发布循环中创建的选项列表中的选择:
<?php
$args = array( 'post_type' => 'office_locations', 'posts_per_page' => -1, 'order_by' => 'title', 'order' => 'ASC' );
$loop = new WP_Query( $args ); ?>
<select style="width: 100%;" name="selectedValue" onchange="this.form.submit()">
<option disabled>Select an office location...</option> // This is disabled
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<option><?php echo get_the_title();?></option>
<?php endwhile; ?>
</select>
因此,如果用户进行了选择,我已将其设置为在选择后发布,有没有办法让选择在发生这种情况后保留在该选项上?
【问题讨论】: