简体   繁体   English

WordPress的get_post_meta

[英]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. 基本上,Wordpress中的get_post_meta允许您从放置在特定帖子中的自定义字段中获取自定义值。 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允许您从Wordpress系统内部获取那些存储的值。

get_post_meta lets you utilize the custom fields functionality of Wordpress: get_post_meta允许您利用Wordpress的自定义字段功能:

http://codex.wordpress.org/Custom_Fields http://codex.wordpress.org/Custom_Fields

Here are some examples of the usage of get_post_meta inside Wordpress: 以下是在Wordpress中使用get_post_meta的一些示例:

http://codex.wordpress.org/Function_Reference/post_meta_Function_Examples 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 好吧,我也不知道,但这是搜索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. 随时从github上检查基本功能并尝试一下。 You'll need to add them to your themes functions.php file. 您需要将它们添加到主题的functions.php文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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