色悠久久久久综合网国产,亚洲中文字幕aⅴ无码天堂,午夜夜伦鲁鲁片免费无码,国产亚洲综合欧美一区二区

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

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

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

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

語法

get_post_format( int $post = null )

參數(shù)

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

返回值

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

實例

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

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

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

講解

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

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

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

微信 13280692153