I have a bit of an issue that is hard to find an answer on. My WordPress structure is like follows:

  • Main Site: domain.com
  • Sub-Site: category1.domain.com
  • Sub-Site: category2.domain.com
  • Etc.

All of these point to the same WordPress installation with the same database. The difference is that on category1.domain.com I query only the posts in the category1 category, same on category2.domain.com etc.

I am NOT running a Multisite setup because it seems to be something different from what I want. (Correct me if I'm wrong)

Anyway, this setup works fine but logging in on the subdomains does not work properly. Users can login on domain.com and stay on the same page they logged in on, but trying to login on category1.domain.com automatically redirects them to domain.com/wp-admin.

The reason why I don't want to have a centralized login page on my main domain.com is because I want a jQuery popup box with a login form on every page on my site, including the subdomains.

It seems that it might have to do with the WordPress Address (URL) and Site Address (URL) settings in wp-admin -> Settings -> General, but I'm unsure how I can set multiple subdomains in this setting.

Does anyone have any idea on how I might get this setup to work? Or am I better off taking a different approach (perhaps using Multisite after all?)

  • So you don't actually want separate admin areas, you just want a login form on every page? Can't you just have a login form on every page that redirects to the admin on the main domain?
    – Cai
    Feb 12, 2016 at 18:32

1 Answer 1


You can dynamically update the WP_HOME and WP_SITEURL constants in wp-config.php to reflect the requested host:

define( 'WP_SITEURL', 'http://' . $_SERVER[ 'HTTP_HOST' ] );
define( 'WP_HOME', 'http://' . $_SERVER[ 'HTTP_HOST' ] );

As long as visitors don't click a link containing a different fully-qualified domain (or otherwise send a request to a different subdomain via a form action or some such), they should remain on the subdomain that was originally requested.

That said, I don't see any reason why the admin dashboard being served on domain.com alone would prevent you from adding a pop-up jQuery login form... If anything, I think it's kind of strange to serve the admin dashboard from those category-centric subdomains when it provides administrative functions for the entire site regardless of which (sub)domain it's accessed from. Intuition would lead me to think the administration dashboard for category1.domain.com would administer category1 alone.

  • Seems like adding define( 'WP_SITEURL', 'http://' . $_SERVER[ 'HTTP_HOST' ] ); to my wp-config.php did the trick! I think the main issue was the jQuery login form trying to make a cross-domain login request (from category.domain.com to domain.com) and failing in the process. Anyway, thank you so much for the answer :)
    – Swen
    Feb 12, 2016 at 21:49
  • Thank you for the answer. You saved me from waking up whole night and try things LOL Jul 11, 2018 at 19:33

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.