如何显示在php中选择的特定类别的帖子?

时间:2019-12-07 14:06:51

标签: php wordpress filtering

我正在尝试在wordpress的现有插件上添加公交公司过滤器。我已经可以从许多公司中选择一个公交公司,但是当我按Enter键时,将显示所有公司可用的所有公交公司。我只想从所选的露营地看到公共汽车。任何帮助将不胜感激。

这是我选择巴士公司的职责

(Hidden field url) Enter a valid URL."

这是我的公交车搜索功能:

function wbtm_bus_name($name, $value = ''){
global $post;
if($post){
$values     = get_post_custom( $post->ID );
}else{
$values ='';
}
$company_name  = 'wbtm_bus_company';

$taxonomies = get_terms($company_name, array(
  "orderby"    => "count",
  'hide_empty' => false,
) );

$hierarchy = _get_term_hierarchy($company_name);


if ( ! empty( $taxonomies ) && ! is_wp_error( $taxonomies ) ) : ob_start(); ?>

    <select name="<?php echo $name; ?>" class='seat_type select2'>

        <option value=""><?php _e('Select a company','bus-ticket-booking-with-seat-reservation')?></option>

        <?php
        // *************custom for form campany ****************
        foreach ( $taxonomies as $taxonomie ) : 

            $selected = $type_name == $taxonomie->name ? 'selected' : '';

            if( ! empty( $value ) ) $selected = $taxonomie->name == $value ? 'selected' : '';
            printf( '<option %s value="%s">%s</option>', $selected, $taxonomie->name, $taxonomie->name );

        endforeach; ?>

    </select>

<?php endif;
          $content = ob_get_clean();
          return $content;
}

0 个答案:

没有答案
相关问题