开发者

Wordpress get_post_meta

开发者 https://www.devze.com 2022-12-19 23:29 出处:网络
I 开发者_开发问答want to retrieve url to last post image with get_post_meta method, but I don\'t know how, and what paramaters are needed.Basically get_post_meta inside Wordpress allows you to obtain

I 开发者_开发问答want to retrieve url to last post image with get_post_meta method, but I don't know how, and what paramaters are needed.


Basically get_post_meta inside Wordpress allows you to obtain custom values from custom fields that you have placed in a specific post. Perhaps you have a vote box, or a mood box that users can place information inside. get_post_meta lets you obtain those stored values from inside the Wordpress system.

get_post_meta lets you utilize the custom fields functionality of Wordpress:

http://codex.wordpress.org/Custom_Fields

Here are some examples of the usage of get_post_meta inside Wordpress:

http://codex.wordpress.org/Function_Reference/post_meta_Function_Examples


Well, I don't know either but this is the first result for googling wordpress get_post_meta: http://codex.wordpress.org/Function_Reference/get_post_meta

Usage:
<?php $meta_values = get_post_meta($post_id, $key, $single); ?>


I've written some simple templating functions that enable you to use the meta data (custom data) in your theme. You can write a template function for any meta data key/value pair, and render it in a theme file like so:

<?php the_meta_templates($meta_data_keys) ?>
<?php the_template_for($meta_data_key) ?>

Feel free to check out the basic functions from github and give them a try. You'll need to add them to your themes functions.php file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号