Php 如何将文章元从wordpress页面转到另一个页面?

Php 如何将文章元从wordpress页面转到另一个页面?,php,wordpress,Php,Wordpress,我在wordpress中有一个关于页面,我希望它的内容出现在主页上,我通过搜索找到了这个代码 <?php $my_id = 256; $post_id_256 = get_post($my_id); $content = $post_id_256->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content);

我在wordpress中有一个关于页面,我希望它的内容出现在主页上,我通过搜索找到了这个代码

<?php
$my_id = 256;
$post_id_256 = get_post($my_id);
$content = $post_id_256->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content; 
?>  

那很好用。现在页面上还有一个costude字段,我需要也获取-我试图操作上面的代码(特别是第2行和第3行),但是我无法获取costude字段

希望你能帮忙


谢谢

您可以通过以下方式获得自定义文件:

<?php
$custom_field = get_post_meta(256, 'name_of_your_custom_field');
echo $custom_field;
?>

您可以通过以下方式获得自定义文件:

<?php
$custom_field = get_post_meta(256, 'name_of_your_custom_field');
echo $custom_field;
?>

使用以下函数获取帖子的自定义字段值:

$meta_values = get_post_meta($post_id, $key);

使用以下函数获取帖子的自定义字段值:

$meta_values = get_post_meta($post_id, $key);

谢谢,我只需在末尾添加true,例如get_post_meta(256,“name_of_your_custom_field”,true);-多谢了,汉克斯,我只需在末尾加上true,例如get_post_meta(256,“name_of_your_custom_field”,true);-谢谢