Using a cookie it would be:
function get_contact_team_page_content ( $content ) {
if (isset($_COOKIE['alternative_content'])) {
$contact_team = get_post( (int)$_COOKIE['alternative_content'] ); // e.g. contact-team page ID
unset($_COOKIE['alternative_content']);
return $contact_team->post_content;
}
return $content;
}
add_filter( 'the_content', 'get_contact_team_page_content');
In this way ( adding the code above in functions.php of your theme or plugin) you can filter the_content
based on the existence of a cookie
in you page you attach a function to the click button that reloads the page:
<!-- 158 is your contact-team page ID -->
<button onClick="loadAlternateContent(158)">change</button>
<script>
function loadAlternateContent(post_id){
var date = new Date();
date.setTime( date.getTime() + (1*60*1000) ); //expiration in 1 minute
var expires = "; expires=" + date.toGMTString();
document.cookie = "alternative_content=" + post_id + expires +"; path=/";
window.location.reload();
}
</script>
you see the content is the post_id 158 content but the url is the same.
At this point, reloading the page manually, the first time will still show the alternative content since the cookie has been deleted by PHP but it's still living in the browser. To avoid this behaviour you should have a function that deletes the cookie on the 'alternative_content' page:
<script>
window.addEventListener("load", function(event) {
document.cookie = 'alternative_content=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
});
</script>