[ad_1]
Hi
I have a function that needs to store the current blog’s id in the cookie.
The function I have is this inside **functions.php**:
function set_post_id_in_cookie() {
if (!is_single(‘post’)) return
$post_id = (string) get_the_ID();
return setcookie(‘post_id’, $post_id, time()+86400*30*12, ‘/’);
}
add_action( ‘after_setup_theme’, ‘set_post_id_in_cookie’ );
I have 2 issues:
1. `is_single(‘post’)` always returns false on single posts/blogs. Why?
2. `get_the_ID()` returns `false`. Why?
Any help is appreciated. Thanks
​
[ad_2]