E:“圖片視頻”的列表頁(taxonomy-cat_media.php)

來源:互聯網
上載者:User

標籤:++   dia   類對象   tar   class   article   for   地址   _id   

擷取本頁的分類ID
<?php get_header();//擷取本頁的分類ID$cat_title = single_cat_title(‘‘, false);   //本頁分類的名稱$cats = get_term_by( ‘name‘, $cat_title, ‘cat_media‘ );  //根據名稱擷取分類對象$cat=  $cats->term_id;  //根據分類對象擷取分類id ?>
輸出本分類的文章
//自訂分類同預設分類一樣,也直接用have_posts()即可,不用query之類的
<ul> <?php $num = 0; //每行第3個右側樣式不同 while( have_posts() ) { the_post(); $url = get_field("post_vedio_url",get_the_ID()); //AFC自訂欄位(根據文章ID擷取視頻地址) if(!$url){ $url = get_field("post_img",get_the_ID()); //如果視頻地址為空白,賦值圖片地址 } if($num%3==0){ echo ‘<article class="hd_web_con">‘; //如果模數為0,弄開頭標籤 } ?> <div class="hd_web_c_l"> <a target="_blank" href="<?php echo $url; ?>"> <img width="270" height="200" src="<?php echo get_field("post_img",get_the_ID()); ?>"> </a> </div> <?php if($num%3==2){ echo ‘</article>‘; //如果模數為2,弄結尾標籤 } $num++;}?> </ul>

 

 

 

輸出其父類下的所有分類
<!--輸出父類下的各自訂分類---> <ul class="list"><?php    $args=array(      "hide_empty"=>0,   //空也顯示    "orderby"=>"ID",      //按id排序    "taxonomy"=>"cat_media"   //自訂分類名(必須有)  );       $categories = get_categories($args);   //根據args參數擷取分類的集合     foreach ($categories as $obj) { ?>          <li class="<?php if($cat ==$obj->cat_ID ) echo"thistab"; ?>">            <a href="<?php echo get_category_link($obj->cat_ID) ?>">                <?php  echo $obj->cat_name;  ?>            </a>           </li><?php 
    }
?></ul>

dddd

 

E:“圖片視頻”的列表頁(taxonomy-cat_media.php)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.