Ниже приведен код, в котором перечислены города в порядке возрастания. Я хочу перечислить города в соответствии с порядком, в котором я выбираю города из внешнего интерфейса. Это шорткод, созданный темой. Cities - это пользовательская таксономия здесь.
Как мне это сделать, пожалуйста, посоветуйте?
Снимок экрана с перечнем городов в AS C порядок: https://prnt.sc/s87to8 выбор внутреннего города https://prnt.sc/s87gyi
просмотр. php
<?php
if (!defined('FW')){
die('Forbidden');
}
/**
* @var $atts
*/
$title = !empty( $atts['title'] ) ? $atts['title'] : '';
$description = !empty( $atts['description'] ) ? $atts['description'] : '';
$cities = !empty( $atts['city'] ) ? $atts['city'] : array();
$city_buttons = !empty( $atts['city_buttons'] ) ? $atts['city_buttons'] : array();
?>
<?php if ( !empty( $cities ) ) { ?>
<div class="tg-popularcities">
<?php
$terms = get_terms( array(
'taxonomy' => 'cities',
'include' => $cities,
'hide_empty' => 0
) );
if ( !empty( $terms ) ){
foreach ( $terms as $key => $value ) {
$country_name = '';
$get_cities_meta = fw_get_db_term_option( $value->term_id, 'countries' );
if (!empty($get_cities_meta['country'][0])) {
$country_id = $get_cities_meta['country'][0];
$country_term = get_term($country_id, 'countries');
$country_name = $country_term->slug;
}
$city_name = $value->slug;
$custom_url = "?country=".$country_name."&city=".$city_name;
$term_data = fw_get_db_term_option( $value->term_id, 'cities' );
$cat_image = !empty( $term_data['image']['url'] ) ? $term_data['image']['url'] : get_template_directory_uri().'/images/locations/city.jpg';
$total_users = listingo_get_total_users_under_taxanomy($city_name,'number','city');
?>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<div class="tg-topcity">
<figure class="tg-cityimg">
<img src="<?php echo esc_url( $cat_image ); ?>" alt="<?php esc_html_e('City Image', 'listingo'); ?>">
<figcaption>
<h3><a href="<?php echo esc_url( get_term_link( $value->term_id, 'cities' ) ); echo esc_attr( $custom_url ); ?>"><?php echo esc_attr( $value->name ); ?></a></h3>
<span><?php echo esc_attr( $total_users ); ?> <?php esc_html_e('Listings', 'listingo'); ?></span>
</figcaption>
</figure>
</div>
</div>
<?php } } ?>
</div>
<?php } ?>
опции. php
<?php
if (!defined('FW'))
die('Forbidden');
$options = array(
'title' => array(
'label' => esc_html__('Heading', 'listingo'),
'desc' => esc_html__('Add section heading. leave it empty to hide.', 'listingo'),
'type' => 'text',
),
'description' => array(
'type' => 'wp-editor',
'label' => esc_html__('Description', 'listingo'),
'desc' => esc_html__('Add section description. leave it empty to hide.', 'listingo'),
'tinymce' => true,
'media_buttons' => false,
'teeny' => true,
'wpautop' => false,
'editor_css' => '',
'reinit' => true,
'size' => 'small', // small | large
'editor_type' => 'tinymce',
'editor_height' => 200
),
'city' => array(
'type' => 'multi-select',
'label' => esc_html__('Select Cities', 'listingo'),
'population' => 'taxonomy',
'source' => 'cities',
'prepopulate' => 500,
'desc' => esc_html__('Show cities as per your selection. Leave it empty to show from all.', 'listingo'),
),
'city_buttons' => array(
'type' => 'addable-box',
'label' => esc_html__('Add Button', 'listingo'),
'desc' => esc_html__('', 'listingo'),
'box-options' => array(
'button_text' => array('type' => 'text'),
'button_link' => array('type' => 'text'),
),
'template' => '{{- button_text }}', // box title
'box-controls' => array(// buttons next to (x) remove box button
'control-id' => '<small class = "dashicons dashicons-smiley"></small>',
),
'limit' => 1, // limit the number of boxes that can be added
'add-button-text' => esc_html__('Add', 'listingo'),
'sortable' => true,
),
);