我想使用get_post_meta
方法检索网址到上一个帖子图片,但我不知道如何以及需要什么参数。
答案 0 :(得分:2)
Wordpress中基本上get_post_meta
允许您从已放置在特定帖子中的自定义字段中获取自定义值。也许你有一个投票箱,或者一个用户可以在里面放置信息的情绪箱。 get_post_meta允许您从Wordpress系统中获取这些存储的值。
get_post_meta
可让您使用Wordpress的自定义字段功能:
http://codex.wordpress.org/Custom_Fields
以下是一些在Wordpress中使用get_post_meta的例子:
http://codex.wordpress.org/Function_Reference/post_meta_Function_Examples
答案 1 :(得分:0)
嗯,我也不知道,但这是Google搜索wordpress get_post_meta
的第一个结果:http://codex.wordpress.org/Function_Reference/get_post_meta
<强>用法强>:
<?php $meta_values = get_post_meta($post_id, $key, $single); ?>
答案 2 :(得分:0)
我编写了一些简单的模板功能,使您可以在主题中使用元数据(自定义数据)。您可以为任何元数据键/值对编写模板函数,并将其呈现在主题文件中,如下所示:
<?php the_meta_templates($meta_data_keys) ?>
<?php the_template_for($meta_data_key) ?>
随意查看github的基本功能并尝试一下。您需要将它们添加到主题functions.php文件中。