久青草国产观看在线视频,在线观看欧美日女,777毛片,亚洲国产精品99久久久久久久

WordPress獲取頁面信息函數:get_page_by_path

2016-10-16 wordpress函數
  • 文章介紹
  • 快速入門
  • 評價&建議

描述

wordpress通過頁面的路徑獲取頁面信息

使用

  1. <?php?get_page_by_path(?$page_path,?$output,?$post_type?)??>

參數

$page_path

(string) (必須) 頁面路徑

Default: None

$output

(string) (可選) 輸出類型. OBJECT, ARRAY_N, or ARRAY_A.

Default: OBJECT

$post_type

(string) (可選) 文章類型.

Default: page

返回的值

(mixed)

Null when complete.

示例

這個等價于通過 ‘pagename’ 來查找, 類似: ‘index.php?pagename=parent-page/sub-page’.

Code for the above could be written as (assuming ‘parent-page/sub-page’ is actually the path to a page):

  1. get_page_by_path('parent-page/sub-page');

For non-heirarchical custom post types, you need to use just the slug in tandem with the post_type parameter.

//Returns nothing, assumes animals is the rewrite slug for the animal CPT

  1. get_page_by_path('animals/cat',?OBJECT,?'animal');

//Returns the animal with the slug ‘cat’

  1. get_page_by_path('cat',?OBJECT,?'animal');

The functions basename() and untrailingslashit() are handy for grabbing the last part of the URL for this:

$page_path = ‘animals/cat/’;

  1. get_page_by_path(?basename(?untrailingslashit(?$page_path?)?)?,?OBJECT,?'animal');

源文件

get_page_by_path() 位于wp-includes/post.php.

0 0

企業建站推薦正版商業主題,國內專業團隊開發,完善售后,是您不二選擇。

正版主題商店

主題貓WP建站,累計幫助1300+客戶成功建站,為站長提供支持!

立刻開啟你的建站之旅
QQ在線客服

服務熱線

wordpress建站咨詢