If you don’t give the cookie an expires time it will only be available during that session. You will also need to destroy an existing cookie if it is already set.
jQuery(function() {
jQuery('#categoriesform').submit(function(e) {
if (jQuery.cookie('my_cookie') ) { jQuery.cookie( 'my_cookie', null) }
jQuery.cookie('my_cookie', 'my_value', { expires: 30 });
});
});
Have you tested to see if the cookie is being set? Use the network tab in chrome developer tools and load the page. Click on the first item on the left which will be the url of your site then click on cookies tab and see if the cookie is there.
When reading your cookie you should also check to see if it’s there.
if (isset($_COOKIE['my_cookie'])) {
$termID = $_COOKIE['my_cookie'];
Related Posts:
- How to show a hierarchical terms list?
- Why does get_term() require taxonomy? Are term_ids not unique?
- get term by id without taxonomy
- Taxonomy terms sort by… Last name!
- WordPress – Creating multiple versions of the same single-customtype.php depending on selected taxonomy categories
- Exclude custom taxonomy from search results and archive pages
- get_terms with posts that have a different taxonomy with term x
- check if tag exists in wp database
- Get_term_by only returns one item from array
- How to have “the most used tags” taxonomy always expanded?
- Get parent and first child taxonomy terms?
- Count posts for each taxonomy term for each month
- What hooks/filters are there to alter selected terms on post save?
- Filter blog archive by category in URL
- Custom Roll/Custom Post Type – Can’t Select Categories
- Get and loop posts with all taxonomy terms
- Unable to delete a Category and Tag that share same slug
- taxonomy/category term in URL slug irrelevant for post?
- How to use a Term Meta Field as a link
- Embed YouTube video on category description
- Manually query posts by taxonomy with MySQL
- Custom Taxonomy leads to 404 page
- Show only, when taxonomy has posts?
- Convert Custom Post Types to Custom Taxonomies
- How do I query a taxonomy term range
- List a current posts’ taxonomy terms in a widget in WordPress
- How can i list the categories of a post type, the taxonomy
- get_terms problem : related articles
- Set post terms on post publish
- Why “Warning: Invalid argument supplied for foreach()”
- WordPress User Taxonomy Saved Values
- Display Taxonomy Description on edit-tags screen?
- get_the_terms error
- How can I find the taxonomy in edited_{taxonomy}?
- extend HierarchicalTermSelector function with custom renderTerms
- Searching in wordpress using wp_term_taxonomy table
- “AND” relation in custom taxonomies
- Attaching taxonomy data to taxonomy with wp_insert_post
- Problem with orderby
- Problem with Query on Taxonomy
- Taxonomy archive + query attachments = duplicate results
- Exclude posts which have any term in a certain taxonomy from the query
- Comma separated tax terms, with “and” before last item [duplicate]
- the_terms characters not limiting
- How to add and display a taxonomy term image in any template? (Taxonomy Images)
- Hierarchical list of custom taxonomy terms
- Get Link to Feed On Term or Taxonomy
- Creating links to a page displaying posts from a particular category
- HTML in category name
- How to get my register taxonomy
- How can I completely hide a taxonomy term from “frontend”? [closed]
- How to relate a user object to taxonomy term?
- How to display taxonomy term custom meta (using wp_get_object_terms?)?
- How to get if child category of this category is empty?
- Adding inline help to category/taxonomy checkboxes in admin sidebar
- Taxonomy vs Post Status
- Automatically show ‘taxonomy’ meta box by default in Appearance > Menus?
- Retrieve all term IDs of post
- Prevent certain subscribers from seeing specific taxonomies (changes frequently)
- child_of not working in wp_dropdown_categories
- How to display posts from two taxonomies?
- Using taxonomies to handle layout?
- update_term_meta not working
- Getting more info about the taxonomy?
- Calling an Archive Page with specific Tag/Tax ID
- Assign Multiple Values from Post Fields to Taxonomy Terms
- how can send a parameter by click on gender-link to filter a post by gender and product taxo
- How to make HTML select options searchable
- Why doesn’t ‘post__not_in’ work with ‘cat’?
- How best to add Author or Artist to product
- Order custom taxonomy hierarchy
- Including taxonomy in searches
- Different Sidebar for same Taxonomy
- How Do I Register Two Taxonomies with one Parent of the Other?
- I want to change the slugs of my terms dynamically
- Translation ready code format for taxonomy
- taxonomy_edit_form_fields output after term fields
- Make/create a category for every page
- All tag/category/custom taxonomy archives 404
- Get a specific category in multiple categories
- Create multidimensional array of taxonomies
- $product->ID in has_term() not working, but manually inputting the ID works, why?
- Can I have have terms with the same slug in the same taxonomy?
- how do you get one specific term from a shortcode attribute?
- How to customize taxonomy edit page
- Fatal error Call to a member function filter()
- Using is_tax with multiple taxonomies
- Taxonomy pages, stop them indexing or being generated?
- Categorizing posts by location
- How to filter the terms to a special custom taxonomy?
- Pages throwing 404 error on server load
- Display yesterday’s last post’s Custom field from Unique terms of one Taxonomies
- Apply custom taxonomy archive template to children
- Why does my taxonomy code display the first alphabetical term?
- Custom Taxonomy link out the loop
- Why can’t I exclude a term ID from either get_terms or WP_Term_query?
- IF taxonomy archive is hierarchical THEN
- What is the ‘selected’ parameter in wp_dropdown_categories() for?
- get_terms of specific parent (including the parent itself)
- is there a hook filter to get custom fields for taxonomy name instead of the default field?