There are some fundamental misunderstandings happening here, but importantly:
- The variables on the main query are what are used to decide which conditionals are true. E.g. will
is_home
return true, isis_search
true? It does this by inspecting the query variables.- It’s these conditionals and variables that are then used to decide which template should be loaded.
- For some reason you’ve specified that
country
is a query variable, therefore if it’s defined it cannot be the homepage.- This is why random parameters don’t trigger this, because they are URL parameters, but they aren’t ingested into
WP_Query
and affect the main post query - This is also why
/?s=test
will loadsearch.php
instead ofhome.php
orfront-page.php
- This is why random parameters don’t trigger this, because they are URL parameters, but they aren’t ingested into
- If I create a page, give it a page template, then set it as the blog or homepage, that page template I set is ignored and does not factor into the decision making about which template to use.
- The front page is not your homepage. In a lot of situations it is, but that is coincidental.
- The front page is the first page of the default post archive.
- On most sites this just happens to be the homepage, but it can be moved
- The homepage template is
home.php
, notfront-page.php
.
By default the homepage and the frontpage are the root of your site, and share the same URL, but if you use these options their locations change:
The frontpage is what you chose for “Posts”, and specifically that URL, the second page or customised versions with additional query parameters don’t count.
The most direct solution to your problem, is to not add country
as a query variable, especially since you aren’t using it that way either and reading the value directly from $_GET
, which suggests it’s being misused.
Query variables are meant to be used for setting parameters on WP_Query
to aid in rewrite rules and extending support for database clauses. They’re not meant to be used to read in URL parameters from forms or options. E.g. if you wanted to hide ?country=US
and replace it with country/US
via a rewrite rule, then a query variable makes sense.