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。否则,返回站点对象。

$pre = apply_filters( 'pre_get_site_by_path', null, $domain, $path, $segments, $paths );

常见问题

FAQs
查看更多 >