Last active
September 29, 2015 13:39
-
-
Save mgibbs189/5ae56afdebfb59c6897b to your computer and use it in GitHub Desktop.
FacetWP - store post IDs into a cookie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| (function($) { | |
| $(document).on('facetwp-loaded', function() { | |
| var cookie_data = JSON.stringify(FWP.settings.post_ids); | |
| setCookie("fwp_posts", cookie_data, 7); | |
| }); | |
| })(jQuery); | |
| function setCookie(cname, cvalue, exdays) { | |
| var d = new Date(); | |
| d.setTime(d.getTime() + (exdays*24*60*60*1000)); | |
| var expires = "expires="+d.toUTCString(); | |
| document.cookie = cname + "=" + cvalue + "; " + expires; | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment