pre_get_site_by_path

過濾鉤子
apply_filters( 'pre_get_site_by_path', null, $domain, $path, $segments, $paths )
引數
  • (null|false|WP_Site) $site Site value to return by path. Default null to continue retrieving the site.
    Required:
  • (string) $domain The requested domain.
    Required:
  • (string) $path The requested path, in full.
    Required:
  • (int|null) $segments The suggested number of paths to consult. Default null, meaning the entire path was to be consulted.
    Required:
  • (string[]) $paths The paths to search for, based on $path and $segments.
    Required:
定義位置
相關勾子
pre_get_network_by_pathpre_get_sitespre_get_main_site_idparent_theme_file_pathpre_get_block_template
相關方法
get_site_by_pathget_page_by_pathget_category_by_pathget_network_by_pathwp_get_sidebarget_site_option
引入
3.9.0
棄用
-

pre_get_site_by_path – 這個鉤子在多站點設定中按路徑檢索站點之前被呼叫。開發者可以使用這個鉤子來修改網站查詢或提供一個基於路徑的自定義網站。

根據站點的域和路徑確定站點。

這允許您縮短預設邏輯,也許可以用更適合您設定的例程替換它。

返回null以避免短路。如果在請求的域和路徑中找不到站點,則返回false。否則,返回站點物件。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$pre = apply_filters( 'pre_get_site_by_path', null, $domain, $path, $segments, $paths );
$pre = apply_filters( 'pre_get_site_by_path', null, $domain, $path, $segments, $paths );
$pre = apply_filters( 'pre_get_site_by_path', null, $domain, $path, $segments, $paths );

常見問題

FAQs
檢視更多 >