最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - Where is the coding error for the unexpected '}' in this ifelse choice of loops?

programmeradmin4浏览0评论

an unexpected '}' is reported for } else {

<?php
function mg_get_selected_taxonomy_dropdown_term() {
  return isset( $_GET[ 'state' ] ) && $_GET[ 'state' ] ? sanitize_text_field( $_GET[ 'state' ] ) : '';
  }
      $selected_term = mg_get_selected_taxonomy_dropdown_term();
      $states = get_terms('state'); $i = 0;

      if ($selected_term != "ALL") {
        foreach ( $states as $state ) :

        $doctors = new WP_Query(array(
         'post_type'      => 'doctor',
         'orderby'        => 'name',
         'order'          => 'ASC',
         'post_status'    => 'publish',
         'posts_per_page' => -1,
         'tax_query'      => array(
          'relation' => 'AND',
          array(
            'taxonomy' => 'state',
            'field'    => 'slug',
            'terms'    => $state->slug
          ),
          array(
            'taxonomy' => 'state',
            'field'    => 'term_id',
            'terms'    => $selected_term,
          ),
        )
      )); 
      } else {
        foreach ( $states as $state ) :

        $doctors = new WP_Query(array(
         'post_type'      => 'doctor',
         'orderby'        => 'name',
         'order'          => 'ASC',
         'post_status'    => 'publish',
         'posts_per_page' => -1,
         'tax_query'      => array(
          array(
            'taxonomy' => 'state',
            'field'    => 'slug',
            'terms'    => $state->slug
          ),
        )
      ));

      }
?>
发布评论

评论列表(0)

  1. 暂无评论