I have the following function where I would like to replace the image nopic.jpg
I have updated by deleting some redundant options.
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;
When done, everything works fine for about an hour and then I get the following error:
the function TaskerDev_get_first_post_image_fnc() cannot be called twice, it's been called in the parent already (just paragraphing what it says)
What is the most efficient way to update the image by been able to called it within the child theme. IS there a short hook or action maybe? Thanks.
if ( ! function_exists( 'TaskerDev_get_first_post_image_fnc' ) ) :
and thisendif;