## Use alternative front page if cookie is set

Question

By default, I present the user with the "Home" front page (set in "Settings / Reading / Homepage").

I have a duplicate page of this called "Alt Home", with some changed content.

When the user goes to the front page, if the "use_alt_home" cookie exists (which I set based on certain conditions), I want to show the user the "Alt Home" page instead (not redirect, load the "Alt Home" page at the "mywebsite.com" address, instead of the "Home" page).

I tried the following code:

function use_alt_home_page( $page_id ) {$alt_home_id = 105;

return $page_id; } if ( isset($_COOKIE['alt_home_page'] ) ) {
return $alt_home_id; } return$page_id;
}