• Resolved Wayne

    (@waynep16)


    When you do a search and view a job, then go back to search results the options are now empty, is there a way to store the search criteria in a cookie or something to make this work ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • That isn’t a feature that’s built-in to WP Job Manager, but may be something that you could accomplish with some custom code. If this feature is important to you, I would recommend using a service like Codeable to work with a freelance WordPress developer to assist in implementing it.

    You will need to modify the search form to save the search criteria as a cookie or you can use a session storage instead of cookies. you would add in your current themes js folder something like this:

    mytheme/js/custom-script.js and add the following code:

    document.addEventListener('DOMContentLoaded', function() { var searchForm = document.querySelector('.search-filter-wrap form'); if (searchForm) { searchForm.addEventListener('submit', function() { var keywords = document.querySelector('input[name="search_keywords"]').value; var location = document.querySelector('input[name="search_location"]') ? document.querySelector('input[name="search_location"]').value : ''; var region = document.querySelector('select[name="search_region"]') ? document.querySelector('select[name="search_region"]').value : ''; sessionStorage.setItem('search_keywords', keywords); sessionStorage.setItem('search_location', location); sessionStorage.setItem('search_region', region); }); if (sessionStorage.getItem('search_keywords')) { document.querySelector('input[name="search_keywords"]').value = sessionStorage.getItem('search_keywords'); } if (sessionStorage.getItem('search_location')) { document.querySelector('input[name="search_location"]').value = sessionStorage.getItem('search_location'); } if (sessionStorage.getItem('search_region')) { document.querySelector('select[name="search_region"]').value = sessionStorage.getItem('search_region'); } } });


    I have not tested this so it’s best to do this in a dev or staging environment.

    Thread Starter Wayne

    (@waynep16)

    @tkgnewseed I feel this is almost going to work but my search filters are ajax with no submit button son the event listener doesn’t work. See here https://cedarrecruitment.dev/browse-jobs/ (password go6) and let me know how I can make changes to suit?

    Plugin Support Deric (a11n)

    (@dericleeyy)

    @waynep16 You mentioned that the search fields does not retained the information after using the browser back function.

    However, we were not able to replicate this issue. Example:

    https://ibb.co/0sySWVY

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Retain search criteria on search’ is closed to new replies.