init
is too early (it happens before the main query), use the action template_redirect
instead.
And for the ID use get_the_ID()
.
Example:
if ( is_singular() )
setcookie( get_the_ID(), 'visited',time() + ( DAY_IN_SECONDS * 31 ) );
Related Posts:
- Is it possible to use a single custom post as the site front page
- Listing a post’s categories and subcategories
- Single post comment template not working
- How do I show google ads between post content?
- Add inline style to get_the_category_list
- Help with figuring out the future post workaround
- Disable single view for specific post category
- Only nextpagelink on wp_link_pages
- Display a post map on a blank/new page
- How To Pass Current Post Type ID from Single Template To Custom Page Template
- Is it possible to create rel=”noindex, nofollow” for a single post if contain bad keywords?
- Custom seperate Single.php
- Custom post type not respecting template hierarchy
- diffrent style for post single page
- WordPress object for comments frame [closed]
- I’m having a problem viewing the Youtube video
- Use different «Single.php» for custom categories
- force https except one page/post
- Single custom post type template not working (single-custom_post_template.php) not working
- Single.php category entries not showing right colours
- Link from archive-page.php to single-page.php
- How to check if a post is in categories x,y,z inludint their subcategories
- Changing the display of the themename_posted_on() function
- How to Highlight current category on category and single page template?
- Exclude single page from function
- WordPress, alternative single post template
- get full real path of thumbnail post img wordpress
- how to loop through this in blog single?
- Modify post template on Divi Theme
- I want to signin from first wordpress site to other wordpress website without registration..without using network mode
- Try to showing product file size on product single page
- Improve related posts
- Get active term on single (CPT) page
- Having single posts appear under the blog homepage and highlight menu items properly?
- Single.php loading fully on localhost but not on server
- explain why is_single doesn’t work
- How to delete a cookie?
- Set cookie and get cookie with JavaScript
- Where does Chrome store cookies?
- Cookies vs. sessions
- What is PHPSESSID?
- javascript set cookie with expire time
- display variable image using cookies
- jQuery $.cookie is not a function
- How do I set/unset a cookie with jQuery?
- Make Axios send cookies in its requests automatically
- How do I create and read a value from cookie?
- How do I expire a PHP session after 30 minutes?
- How to use cookies in Python Requests
- Get cookie by name
- Cross-Domain Cookies
- What is the difference between localStorage, sessionStorage, session and cookies?
- Check if a PHP cookie exists and if not set its value
- Local Storage vs Cookies
- How do I check if a cookie exists?
- Create, read, and erase cookies with jQuery [duplicate]
- PHP – setcookie(); not working
- Why am I getting “Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute”?
- Unset cookies php
- How can I block doubleclick.net cookie from my wordpress website?
- How can I block doubleclick.net cookie from my wordpress website?
- Automatic WordPress Login of Logged In ClickFunnels User
- php, cookies, wordpress – how to make automatic login in one one site, login and on other one
- WordPress dFactory Cookie Notice Plugin
- How to include landing page with form submission?
- How to disable the single view for a custom post type?
- How to check if the product is in a certain category on a single-product.php in Woocommerce?
- Can’t log in: “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
- Is this Solution for Caches vs Cookies Going to Get Me in Trouble?
- Custom post type single page returns 404 error
- Custom post type single-{custom}.php not working
- Login page ERROR: Cookies are blocked due to unexpected output
- Setting custom cookies in WordPress
- What is singular.php?
- How to detect single.php (but not single-portfolio.php)?
- Conditional for single-{post-type}.php
- Check IF is a “single product page” and Check the “role” for a Redirect
- How to validate a user from ouside wordpress/php?
- Removing username from the ‘wordpress_logged_in’ cookie
- How to modify single.php in a child theme?
- Passing current cookies in wp_remote_get to get Draft Post Preview
- How to share cookies and sessions between domain and subdomain?
- Add_action to wp_head via functions.php
- why does WordPress need two cookies for auth/login
- How to Layer 7 Load Balance WordPress Backend and Frontend?
- Is it possible to transfer a WordPress session to a different browser via query string?
- wp_set_auth_cookie() doesn’t work in Ajax call
- Custom Single Post By Category
- How does REST API cookie authentication work in WP 4.7?
- How to mark articles as read?
- What is the purpose of having a token in cookies?
- Why does it say: ‘Cookies are blocked or not supported’?
- Using single.php from plugin folder instead of default template folder
- Template for specific post of custom post type
- How do I get the category URL from get_the_category?
- Passing Additional Parameters to add_filter Callable
- Set cookie using GET variable
- Modifying the way WP sets cookies
- Custom permalink structure only for default posts
- How to set custom cookies before output