I moved my WordPress site from localhost to a live hosting service and now I’m having weird issues. The site works fine when I’m logged into my admin account, but breaks when I log out.
My main problem is with a language switcher that uses cookies. I have flags for English (cookie value 0) and Hungarian (cookie value 1). When I click a flag, the cookie changes correctly and the current page switches languages. But when I navigate to other pages, it reverts to the old language. The cookie is still there in the browser, but pages don’t read it properly until I do a hard refresh.
Another strange thing is that when I update the header.php file, the changes only show on the homepage. All other pages keep showing the old header content even after clearing cache.
Some details about my setup:
Each page has its own PHP template file named like page-example-slug.php
sounds like a database url problem. did you update all the wordpress urls in the database when you migrated? there’s usually hardcoded localhost urls still hanging around in the wp_options table that mess things up for logged-out users. run a search/replace on your database to swap any leftover localhost references for your live domain. the cookie issues are probably happening because wordpress is still trying to pull resources from those old localhost urls.
I’ve seen this exact issue before - it’s a server configuration problem with URL rewriting. Since logged-in users see everything fine but anonymous users don’t, your .htaccess file isn’t configured right for your live server. Moving from localhost to live hosting changes the server setup, and rewrite rules that worked locally often break. The language switcher cookie issue happens because the server can’t process URL rewrites for non-logged-in users, so pages aren’t executing the PHP code that reads your cookies. Same thing with header.php changes only showing on the homepage - your other templates aren’t loading through WordPress routing properly. First, try regenerating permalinks by going to Settings > Permalinks and clicking save (don’t change anything). If that doesn’t fix it, compare your live .htaccess file with a fresh WordPress install and make sure all rewrite rules are there.
This is definitely a caching issue mixed with server config problems. I had the exact same thing happen when I migrated a multilingual site last year. The fact that it works fine when you’re logged in but breaks when logged out is a dead giveaway - WordPress skips cache for logged-in users. Your host probably has server-level caching that’s messing with your cookie-based language switching. The cache keeps serving old page versions to anonymous visitors, so the cookie value changes but pages don’t show the new language until you hard refresh. The header.php issue? Same caching problem. Your homepage might be excluded from aggressive caching or has different cache rules. I’d check with your hosting provider about their caching setup first. Most shared hosts use aggressive caching that breaks dynamic stuff like this. You’ll probably need to configure cache exclusions for pages that use cookies or switch to a different language method that plays nicer with server-side caching.