Hello, working with wordpress for the first time. I need to make the template and the data inside it switch by pressing the button, they say winter / summer
I decided to send a get request and, depending on it, set a cookie on which I can then write the conditions for the withdrawal, so I pass it this way,
<a href="<?php echo bloginfo('url')."?weather=summer"?>"> Лето </a> in functions.php
function codenode_set_weather(){ $weather = $_GET['weather']; switch($weather){ case "summer": case "winter": setrawcookie('weather', $weather, time()+3600 * 3); break; default: break; } } add_action('init', $codenode_set_weather); and it seems to me that this is a very clumsy way of a crutch, can it be done more accurately? PS And by the way for some reason it does not work did not move in yet why