[英]Wordpress Custom Field Value from MoreFields not returning value
hello everyone here is the snippet of code I am having problems with... 你好,这里的每个人都是我遇到问题的代码片段...
<?php $ReleaseDate = meta('dvdReleaseDate'); ?>
If I return the value for $ReleaseDate, I get nothing... 如果我返回$ ReleaseDate的值,我什么也不会得到...
I have also tried.... 我也尝试过...
<?php $ReleaseDate = get_post_meta(get_the_ID(), 'dvdReleaseDate', true); ?>
Nothing works..I really need help. 什么都没有。.我真的需要帮助。 I am using Wordpress 3.0.1.
我正在使用Wordpress 3.0.1。 Thanks
谢谢
Try to access this data at the most basic level: 尝试在最基本的级别上访问此数据:
<?php echo 'DVD Release Date:'.get_post_meta($post->ID, 'dvdReleaseDate', true);?>
Make sure you use this call somewhere where your $post object is accessible -- ie, within the loop. 确保在可访问$ post对象的地方(即在循环内)使用此调用。 If you're using this somewhere outside the loop (for example, in functions.php), declare your $post object beforehand like this:
如果在循环之外的某个地方使用此函数(例如,在functions.php中),请事先声明$ post对象,如下所示:
<?php
global $post;
echo 'DVD Release Date:'.get_post_meta($post->ID, 'dvdReleaseDate', true);
?>
If you still get no output from this, it means either: 如果仍然没有得到任何输出,则意味着:
If #3 is in question, try something like this: 如果#3有问题,请尝试以下操作:
<?php
echo 'if there is data in $post, it will print here:';
print_r($post);
echo 'DVD Release Data:'.get_post_meta($post->ID, 'dvdReleaseDate', true);
?>
If your post object doesn't print, then you're experiencing #3. 如果您的post对象没有打印,则说明您遇到了#3。 If it does, but there's no custom field output, it's one of the first 2.
如果可以,但是没有自定义字段输出,则为前两个输出之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.