我有以下功能,我想替换图像nopic。jpg公司
我已通过删除一些冗余选项进行了更新。
if ( ! function_exists( \'TaskerDev_get_first_post_image_fnc\' ) ) :
function TaskerDev_get_first_post_image_fnc($pid, $w = 100, $h = 100) {
//---------------------
// build the exclude list
$exclude = array();
$args = array(
\'order\' => \'ASC\',
\'post_type\' => \'attachment\',
\'post_parent\' => $pid,
\'meta_key\' => \'another_reserved1\',
\'meta_value\' => \'1\',
\'numberposts\' => -1,
\'post_status\' => null,
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$url = $attachment->ID;
array_push($exclude, $url);
}
}
//-----------------
$args = array(
\'order\' => \'ASC\',
\'orderby\' => \'post_date\',
\'post_type\' => \'attachment\',
\'post_parent\' => $pid,
\'exclude\' => $exclude,
\'post_mime_type\' => \'image\',
\'post_status\' => null,
\'numberposts\' => 1,
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
//$url = wp_get_attachment_url($attachment->ID);
return TaskerDev_wp_get_attachment_image($attachment->ID, \'thumb_image_thing\');
}
}
#else return get_bloginfo(\'template_url\').\'/images/nopic.jpg\';
else return get_stylesheet_directory_uri().\'/images/Picture16.jpg\';
}
/*************************************************************
//*
* TaskerDev (c) sitemile.com - function
/
*************************************************************/
endif;
完成后,一切正常工作大约一个小时,然后出现以下错误:
函数TaskerDev\\u get\\u first\\u post\\u image\\u fnc()不能调用两次,它已经在父级中被调用(只是分段描述它所说的内容)
通过在子主题中调用图像,更新图像最有效的方法是什么。是否有短钩或动作?谢谢