Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress类别/子类别_Php_Wordpress - Fatal编程技术网

Php Wordpress类别/子类别

Php Wordpress类别/子类别,php,wordpress,Php,Wordpress,嘿!我需要一个函数,只提取类别的子类别。。在wordpress中,不是子类别的子类别。谢谢 <?php if (is_category()) { $this_category = get_category($cat); if (get_category_children($this_category->cat_ID) != "") { $args = array('child_of' => $this_category->cat_ID);

嘿!我需要一个函数,只提取类别的子类别。。在wordpress中,不是子类别的子类别。谢谢

     <?php if (is_category()) {

  $this_category = get_category($cat);
  if (get_category_children($this_category->cat_ID) != "") {


   $args = array('child_of' => $this_category->cat_ID);
   $subcategorii = get_categories($args);
     foreach($subcategorii as $subcategorie) {
          echo ' <li class="postWrapper" id="categorie"><a href="'.$subcategorie->link.'"><h5>'.$subcategorie->name.'</h5></a>';
          query_posts('cat='.$subcategorie->term_id.'&posts_per_page=3');
          if ( has_post_thumbnail() ) the_post_thumbnail( 'mic' );  
        echo '<ul>';    
        if ( have_posts() ) : while ( have_posts() ) : the_post();

          echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';

      endwhile; 
        echo '</ul>';
        echo '</li>';
      else:
        echo 'niciun articol!'; 
      endif;

    //Reset Query
    wp_reset_query(); 
     }
  } else {
      query_posts('cat='.$this_category->cat_ID.'&posts_per_page=3');
        echo '';
        if ( have_posts() ) : while ( have_posts() ) : the_post();

        echo '<li class="postWrapper" id="post">';

         echo '<a href="'.get_permalink().'">'; if ( has_post_thumbnail() ) the_post_thumbnail( 'mic' );    

          echo '<h3 class="postTitle">'.get_the_title().'</h3></a>'; 




          echo '</li>';

      endwhile; 
        echo '';
      else:
        echo 'niciun articol!'; 
      endif;    
   } 
}

?>

可能是这样的吧

foreach($subcategorii as $subcategorie) {

   if ($subcategorie->post_parent == $this_category->cat_ID) {

   // do stuff

   }  

 } 

记住if语句中的双等号(==和!==)