From the course: WordPress Development: Coding Practice

Unlock the full course today

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

Get post meta

Get post meta

- [Instructor] Setting and displaying post meta is something that revolutionized WordPress, turning it from a simple blog into a content management system. So we want to leverage that feature to store and retrieve additional data along with our standard post data of title and text content and the featured image. So given the provided code, which sets a custom field on the latest post in your WordPress installation, grab the custom field's value to be displayed via shortcode on the post's page. As a reminder, my solution may be different from yours, and that's okay. Here is our starting code. As a reminder, we are setting the custom field. I have set that for you already. I am setting a meta_key of greeting with the value "Hello There!" Feel free to change it in your own solution. And then, the arguments here, really quick, are getting the latest post, the single latest post, ordered by descending and date,…

Contents