'custom_circles' ); $custom_circles = new WP_Query( $args ); if( $custom_circles->have_posts() ) { while( $custom_circles->have_posts() ) { $custom_circles->the_post(); // Get the link $link = get_custom_field( 'link' ); //Add in "http://" if it isn't there already if ( strpos( $link, 'http://' ) === false ) { $link = 'http://' . $link; } // I don't know how to return something useful from // get_custom_field that'll let me know if no image // has been specified, so I'm doing this elongation: // Convert the image to an integer $image_id = (int) get_custom_field( 'image:wrapper'); //If it's more than zero then it has matched if ( $image_id !== 0 ) { $thumb_id = get_custom_field( 'image' ); $thumb = wp_get_attachment_image($thumb_id, 'home-post wp-post-image'); } else { $thumb = '' . esc_attr( the_title_attribute( 'echo=0' ) ) . ''; $postclass = 'no-thumbnail'; } ?>