// get the first medium image associated to the ad // used on the home page, search, category, etc function cp_get_image($post_id = '', $size = 'medium', $num = 1) { $images = get_posts(array('post_type' => 'attachment', 'numberposts' => $num, 'post_status' => null, 'post_parent' => $post_id, 'order' => 'ASC', 'orderby' => 'ID')); if ($images) { foreach ($images as $image) { $img_check = wp_get_attachment_image($image->ID, $size, $icon = false); $img_check = preg_replace('/title=\"(.*?)\"/','', $img_check); } } else { // find the category id of the post $cat_default_pic = get_the_category(***Category ID***); // show the placeholder image if(get_option('cp_ad_images') == 'yes') { $img_check = '[img]'. get_bloginfo('template_url') .'/images/no-thumb'. $cat_default_pic .'.jpg[/img]'; }
There are currently 1 users browsing this thread. (0 members and 1 guests)