You need to set a cookie for this. You can then retrieve the cookie’s value on any page where you need it, or in the header.php
.
There are several ways you can do this, you can set cookies either via php or JavaScript.
Here is a good example on how to set a cookie with php in WordPress. For JavaScript, there are several options. There’s a jQuery cookie plugin, I recommend to google around for the different options.
Related Posts:
- Keep one user logged for a year?
- Disable saving comment details (name, e-mail) in cookie?
- Security error WP 4.0 + WP phpBB Bridge [closed]
- Detecting $_GET parameters from any page + Cookie
- Set cookie then immediantly refresh the page
- Popup Cookie WordPress select language and section (Elementor)
- Do We Need to Validate, Sanitize, or Filter Simple Numerical Superglobals (Cookies and Post)?
- Why is my staging subdomain not sending wordpress_logged_in cookies?
- How to delete Passwrd Protected posts cookies when a user logged out from the site
- How to save generated JWT token to cookies on login?
- WordPress Keeps Logging Out – What Tests Can I Run to Solve This?
- User Session and Stored Cookies not get removed
- Where does the cookie mo_page_views_counter come from?
- How to handle cookies from a WordPress plugin on a cached page?
- Login cookies set as wrong domain
- add_action in a custom plugin
- Blurry images when loading the page first time
- Cookies set by a plugin in wordpress for tracking
- Codeless random token generation to pass into multiple tracking links in a single page load
- Identify User Language, Redirect to the corresponding page and Save the chosen language as Cookie
- Cookie value changes back to previous value after changing
- Display value of the GET parameter in a new URL page
- Block Google tracking on refuse consent of the user with plugin
- WordPress Admin login redirect to homepage
- How can I store user preferences in WordPress and retreive them later?
- WordPress delete cookie
- Why does WordPress use cookies for /wp-admin and /wp-content/plugins for non-admin users [duplicate]
- Implementation to count page visits of unique visitors based on a cookie
- admin-ajax.php not working properly on subdomains
- Cookie set in a plugin visible in admin but not on front
- How can I save cookies to members
- set cookies for my whole site is not working
- WordPress Plugin: Where should I put my cookies for cURL?
- Undefined constant error in pluggable.php
- How to resolve these findings from security audit
- ERROR: Cookies are blocked due to unexpected output – no access to FTP
- How to delete Password Protected posts cookies when a user logged out from the site
- Stop the user if login from the cookies
- How can I prevent a plugin from updating unless it’s minimum PHP version is met?
- wp_enqueue_scripts not working in custom theme
- What characters are allowed as a shortcode tag and how should they be sanitized?
- Additional, optional fee on Woocommerce Checkout [closed]
- Why does including a file in theme’s functions.php not work?
- OEmbed from Pinterest
- disable active plugins for specific theme
- Flickr plugin that will display photos from multiple group pools? [closed]
- How to change ID of an attachment in wp_posts and its related tables correctly?
- Making menu link open in new tab?
- Single Must Use Plugins Directory for local development
- ReOrder Post Within Categories plugin with featured image
- How to initialize something in unit test before the init hook being called?
- Confused about shortcode and settings values
- Running jquery script after shortcode [closed]
- add_filter comment_edit_redirect not working
- How to write a plugin to add users to a mail list
- Two text domains in one plugin
- Plugin or method to delete uploads not in media library?
- Add woocommerce variation images in gallery?
- Add a CSS class based on categroy id to archive pages
- Comment section not showing correctly
- add input in custom javascript from WordPress pages/posts
- WP Plugins – Use includes to display page content
- WordPress as a data-store?
- How do I use add_action on custom widget?
- plugin active error
- (WordPress 5.8.3) Function.php or a plugin for better performance? [duplicate]
- Control page content visibility based on URL parameter
- WooCommerce Shopping Cart Not Initially Showing Products [closed]
- Elementor Custom Control: How to get input value?
- show my own admin_notices after a post has been published
- Play videos with buffering in my server
- Custom form not showing in correct place on page
- Dropdown menu on click change
- Editable select options in quick edit OR in plugin settings
- Send Array from JS to php file then insert it in wp database through a plugin
- How to add the search page link to the anchor tag?
- How to override Plugin javascript function : $(‘body’).on(‘change’,’.class’)
- Possible way of having multiple Gutenberg instances for a page?
- Plugin updates, change file permissions on WordPress
- Creating one user access account for all the multiple sites
- I am Getting Sorry, no posts matched your criteria on form submit only for certain page [duplicate]
- Plugin information tabs show large blank area at top
- Dynamic input fields in WordPress Plugin
- Custom role not listed
- How to fix blog article view and share #’s?
- How to Prevent User From Submitting Property Or View His Posted Properties Before Login in wordpress?
- WordPress SSO SAML
- Attachments plugin cannot click media library button [closed]
- Is there any hook to change media html in post? [duplicate]
- plugins_loaded action is not working properly
- Creating a user ‘add custom field’ section
- WordPress Settings – Custom Button actions
- After installing plugins, changes don’t appear
- Links on FAQ page aren’t working
- How can I make the Twitter Tools plugin hyperlink every link?
- wp insert post not working
- WordPress shortcode plugin not working
- Gutenberg Block to Select Category Term
- Update post meta Rest Api
- How to give specific class name to category in wordpress with code snippets