1

I'd like to do this when clicking on home icon :

  • if we are not on the homepage of a sub-blog, go to the homepage of the sub-blog
  • if we are on the homepage of a sub-blog, go to the homepage of the whole site

I'm beginner and don't know how to detect the context of homepage for a wordpress mu sub-blog, any idea, thanks ?

1 Answer 1

1

You could test using the following conditionals

//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>";
}

Also depending on how your sub-blog homepage is configured, you could use either is_front_page(), is_home().

2
  • Thanks guy for the code will try it as soon as possible :)
    – user310291
    Sep 7, 2016 at 22:07
  • My pleasure! :) Sep 8, 2016 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.