WordPress 3.4 wp_get_theme – new function for retrieving theme data

Another new addition to 3.4 is the deprecation of the get_theme_data function, this function was used pull data from the header of a theme’s stylesheet. This function was useful for outputting theme data in a repeatable way. The new function wp_get_theme is the replacement for this function. The difference is that the get_theme_data returned data in an array and the data was accessible via array keys, while wp_get_theme returns the data as an object. This has little effect on how the code is used just how to retrieve the data.

Maintaining backwards compatibility is always a top priority when releasing a theme for the public. This code below will accomplish this by testing if the new function exists before running it, and falling back to the old function if it doesn’t. The same variables are used for either way, so they variables can be used regardless of what function is used.

About Jeremy Clark

Small town IT worker with interests in all things technological and technical. Biggest interests are in web development especially the WordPress publishing platform and the community supporting it. Currently developing and maintain the free WordPress theme Techozoic. I'm also always available for hire.
This entry was posted in Featured, tech, wordpress and tagged , , . Bookmark the permalink.

3 Responses to "WordPress 3.4 wp_get_theme – new function for retrieving theme data"

Leave a reply

Comments will be sent to the moderation queue.