我有一个网站,有一些自定义的帖子类型。我还安装了Types插件,因此我可以使用自定义字段在网站主页上上载/显示图像。我发现代码似乎与自定义帖子类型有问题。
如果我在自定义帖子类型下面添加代码,则不会显示图像。如果我把代码放在上面,它就会出现。我还尝试删除代码,它会出现。
<?php $pic_of_week = rg_get_social_pic_of_the_week();
$url = get_post_meta($pic_of_week[\'id\'], \'social_pic_facebook_url\', true);
?>
<a id="social_image" href="<?php echo $url;?>" target="_blank">
<div id="social_ofweek">
<?php echo wp_get_attachment_image($pic_of_week[\'thumbnail\'],\'social-pic-of-the-week-thumbnail\'); ?>
</div>
<img id="social_overlay" src="<?php bloginfo(stylesheet_directory); ?>/basemedia/images/socialpic2.png" alt="The Royal George Logo" />
</a>
<?php echo(types_render_field("image_1", array("alt"=>"Product image",
"width"=>"209","height"=>"298","proportional"=>"true"))); ?>
类型插件的代码是-
<?php echo(types_render_field("image_1", array("alt"=>"Product image",
"width"=>"209","height"=>"298","proportional"=>"true"))); ?>
导致此问题的代码是-
pic_of_week = rg_get_social_pic_of_the_week();
$url = get_post_meta($pic_of_week[\'id\'], \'social_pic_facebook_url\', true);
?>
有人能告诉我问题出在哪里吗?
rg\\u get\\u social\\u pic\\u of\\u the\\u week()的代码-
if(!function_exists(\'rg_get_social_pic_of_the_week\')) {
function rg_get_social_pic_of_the_week() {
global $wp_query;
$args = array(
\'meta_key\' => \'pic_of_the_week\',
\'meta_value\' => \'1\',
\'post_type\' => \'social-pic\'
);
$loop = new WP_Query($args);
$social_pics_array = array();
while($loop->have_posts()) {
$loop->the_post();
$social_pics_array[] = array(
\'content\' => get_the_content(),
\'excerpt\' => get_the_excerpt(),
\'id\' => get_the_ID(),
\'thumbnail\' => get_post_thumbnail_id(get_the_ID()),
\'title\' => get_the_title()
);
}
if(count($social_pics_array)) {
return $social_pics_array[0];
}
return $social_pics_array;
}
}