Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Reply To: [Assigned] Repeating images as "background-image" in DIVs ?

$
0
0

Hi robertM,

I assume your custom image field is using slug "image", and created by Types, please try modify 'wpcf-images' as 'wpcf-image'

More help: http://codex.wordpress.org/Function_Reference/get_post_meta

Are you going to set each image as different div's background-image?

Please try this:

	$images = get_post_meta(get_the_ID(), 'wpcf-image');
	$res = '';
	foreach ($images as $index=>$image) {
		$url = do_shortcode('[types field="image" url="true" size="medium" index=' . $index . ']');
		$res .= '<div style="background-image:url( ' . $url . ');">div content for image index: ' . $index . '</div>';
	}
     echo $res;

Viewing all articles
Browse latest Browse all 20145

Trending Articles