首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何检测wordpress mu子博客的主页上下文

问如何检测wordpress mu子博客的主页上下文
EN

WordPress Development用户
提问于 2016-09-07 20:00:46
回答 1查看 181关注 0票数 1

我想在点击“家”图标时这样做:

  • 如果我们不在子博客的主页上,请转到子博客的主页。
  • 如果我们在一个子博客的主页上,请转到整个站点的主页。

我是初学者,不知道如何检测一个wordpress mu子博客的主页上下文,有什么想法吗,谢谢?

EN

回答 1

WordPress Development用户

回答已采纳

发布于 2016-09-07 20:40:17

可以使用以下条件进行测试

代码语言:javascript
复制
//if you aren't on the main site, and aren't on the homepage
if (!is_main_site() && (!is_front_page() && !is_home())) {
  print "<a href='sub-blog-homepage'>home</a>";
}
//if you aren't on the main site, and aren on the homepage
if (!is_main_site() && (is_front_page() && is_home())) {
  print "<a href='main-site-homepage'>home</a>";
}

另外,根据您的子博客主页的配置方式,您可以使用is_front_page()、is_home()。

票数 1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/238529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档