From the course: WordPress Development: Coding Practice

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Create a transient

Create a transient

- [Joe] Transients are a great way to store complex queries or data that takes a long time to generate in order to save on performance. We're going to show a proof of concept transient here by not having to call the user object every time we want to display user information. So the problem, we want to store data easily so we don't need to keep retrieving it separately. We're going to do that by storing the user's display name in a transient. So requirements, check to see if a user logs in, create a transient with their display name, output the transient using the provided shortcode, and when the user logs out, delete the transient. We don't want other people to be greeted by another user's display name. Note that there are actually three functions here. One for storing the transient, one for displaying it, and one you'll need to create for deleting the transient. So with that, let's look at our starter code. You can see we…

Contents