亚洲国产精品久久一线不卡,日韩av片无码一区二区不卡电影 ,欧美搡BBBBB搡BBBBB,18禁裸男晨勃露J毛免费观看

專業(yè)WORDPRESS主題設(shè)計(jì)制作

get_post_format()函數(shù)(form的method有post和get)

發(fā)布于: 2022-08-19

get_post_format()函數(shù)用于獲取文章的形式,在為不同形式的文章制作不同的模板時(shí)非常有用。

語法

get_post_format( int $post = null )

參數(shù)

$post_id 整數(shù)型,默認(rèn)值:null 文章的ID

返回值

  1. aside 日志
  2. chat 聊天
  3. gallery 相冊(cè)
  4. link 鏈接
  5. image 圖像
  6. quote 引語
  7. status 狀態(tài)
  8. video 視頻
  9. audio 音頻

實(shí)例

get_post_format()函數(shù)
get_template_part('content', get_post_format());

get_template_part():根據(jù)get_post_format()返回的信息來加載content開頭命名的相應(yīng)的模板;

get_post_format():獲取當(dāng)前post的形式。

講解

比如我們現(xiàn)在有一個(gè)模板 content-image.php

那么可以通過get_template_part(‘content’, get_post_format())調(diào)用,即如果當(dāng)前post形式是image,也就是對(duì)應(yīng)上面的返回值,那么就會(huì)調(diào)用模板content-image.php;如果返回的post分類模板不存在,那么就會(huì)使用默認(rèn)post模板。

WP技術(shù)資料 wordpress模板制作、wordpress主題開發(fā)相關(guān)知識(shí)常見問題總結(jié)
MORE
服務(wù)電話:
0533-2765967

微信 13280692153