• Hi,
    I have a problem – I have a function that takes the first attached image of a custom post type and renders it. It works great on all pages except one type – the category archive pages. There it doesn’t work at all. Any ideas?
    It is exactly the same code before/after the function on the category pages as for example the home page.

    Here is my function:

    //Thumb img
    function get_first_image($id) {
    	$PostID = $id;
    	$all_images =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . $PostID );
    	if($all_images) {
    	$arr_of_all_images = array_keys($all_images);
    	$firstImage = $arr_of_all_images[0];
    	$thumb_url = wp_get_attachment_thumb_url($firstImage);
    	$First_thumb_image = '<a href="' . get_permalink() . '">' .
    	'<img src="' . $thumb_url . '" width="150" height="150" />' .
    	'</a>';
    	echo $First_thumb_image;
    	}
    }

  • The topic ‘Function not working on archive pages’ is closed to new replies.