我当前正在使用高级自定义字段创建自定义字段has_the_portrait_sold
这将显示在我的Prettypto/Lightbox项目上。
但是,当我使用示例中的PHP时(正确或错误):
if(get_field(\'has_the_portrait_sold\')){
echo "The item has been sold.";
}else{
echo "The item has not been sold";
}
在标题中。php:<script type text/javascript>
jQuery(document).ready(function($) {
$("a[href$=\'.jpg\'], a[href$=\'.jpeg\'],
a[href$=\'.gif\'], a[href$=\'.png\']").prettyPhoto({
theme: \'dark_square\',
show_title: true, /* true/false */
social_tools: \'<?php the_title(); ?> <?php
if(get_field(\'has_the_portrait_sold\')){
echo "do something";
}else{
echo "do something else";
}
?>\'
});
});
</script>
然而,尽管这可能会根据需要在lightbox中包含自定义字段,但它显然只显示当前页面的自定义字段数据。我需要为当前lightbox项目/WordPress的图像附件打印自定义字段数据。因此,我尝试在post-template.php
. 请注意我的PHP技能是有限的,我非常决心使这项工作。
return apply_filters( \'wp_get_attachment_link\', "<a title=\'$post_title\'
href=\'$url\'>$link_text</a><?php
if(get_field(\'has_the_portrait_sold\')){
echo "do something";
}else{
echo "do something else";
}
?>", $id, $size, $permalink, $icon, $text );
}
我觉得我在包含自定义字段调用方面走的是正确的道路post-template.php
. 然而,我只是不具备创建正确调用所需的PHP技能。我想知道这里是否有人能帮忙。我很绝望,但不愿意放弃。提前谢谢。