简体   繁体   中英

Wordpress get_post_meta

我想使用get_post_meta方法检索到上一个帖子图像的url,但是我不知道如何,以及需要哪些参数。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM