WordPress Template_page meta key and update_post_meta

This post will be a fairly simple and straight forward one. It has been a long time since i wrote anything on Hungred Dot Com. I really like to write more regarding my experiences during each of my project and some useful designing list that i would like to keep but i just can’t seems to get the time. Nonetheless, i would still write such article that i couldn’t find on Google to share with people who needs it.

Template_page Meta Key

Since 9 of January 2009, WordPress has removed template_page key from wp_insert_post from the table wp_post to wp_meta_post. Therefore, some of you who are looking for this particular key to insert customize template will find difficulty as there are no documentation of any kind that allows you to work this out peacefully. The changes will require user to use update_post_meta in order to interact with wp_meta_post table. Hence, our main concern here is the exact key used to update any particular post/page template using the method update_post_meta. I dig around and found out that WordPress no longer uses Template_page as the key but uses _wp_page_template as the key for our meta post table. Hence, you will write something like this in order to update a particular post/page template.

update_post_meta($id, "_wp_page_template", "new_template.php");

The third parameter will require you to place in the exact file name plus extension. Without extension but pure name won’t work. Once this sentence is being executed, your post which has the id in the variable $id will have new_template.php as its own template! Enjoy!

 

Like this post? Share it!

digg 48 Wordpress Template page meta key and update post meta reddit 48 Wordpress Template page meta key and update post meta stumbleupon 48 Wordpress Template page meta key and update post meta delicious 48 Wordpress Template page meta key and update post meta furl 48 Wordpress Template page meta key and update post meta technorati 48 Wordpress Template page meta key and update post meta google 48 Wordpress Template page meta key and update post meta myspace 48 Wordpress Template page meta key and update post meta facebook 48 Wordpress Template page meta key and update post meta twitter 48 Wordpress Template page meta key and update post meta
share save 171 16 Wordpress Template page meta key and update post meta

No related posts.

About Clay

I am Clay who is the main writer for this website. I own a small web hosting company in Malaysia and i'm available to be hired as individual contractor on elance. You can find me on twitter.
This entry was posted in How-to, Others and tagged . Bookmark the permalink.

Comments are closed.