M
M
Muvka2018-01-31 09:16:54
WordPress
Muvka, 2018-01-31 09:16:54

How to set cookies in WP?

Can you tell me why you can't set cookies? Here it doesn't work.

setcookie('city_name', get_the_title(), time()+3600*24*7);

I found that it can be set via add_action('init', function() {}); but the problem is that WP_Query doesn't work in this function. And I need to set the value of the page name with an additional field in cookies. How can this problem be solved?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question