Wordpress: Calling custom Image Field in page -
i found great thread on how add multiple custom image fields in post:
adding custom image fields , other fields @ same time
on admin side, works perfectly. using function automatically show added images in post in standard theme-setup. however, calling posts directly, using this:
<?php $post_id = 222; $queried_post = get_post($post_id); $content = $queried_post->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); ?> <h2><?php echo $queried_post->post_title; ?></h2> <?php echo $content; ?>
and after want manually add images put in custom field.... can't figure how these images stored , how call them. it's quite simple missing knowledge know wordpress commands...
any appreciated!
edit:
i got working, it's not pretty. mevius showed me how use get_post_meta
put values in array (thx that), produces array in array in array. image's urls use this:
<?php $queried_imagemeta = get_post_meta( $post_id, 'gallery_data', $gallery_data ); foreach ($queried_imagemeta $imagearray) { foreach ($imagearray $imageurl) { foreach ($imageurl $singleimage) { ?> <img src="<?php echo $singleimage; ?>" class="customfield-image"/> <?php } } } ?>
which works, looks awful. way, how array built in functions.php:
$gallery_data = array(); ($i = 0; $i < count( $_post['gallery']['image_url'] ); $i++ ) { if ( '' != $_post['gallery']['image_url'][ $i ] ) { $gallery_data['image_url'][] = $_post['gallery']['image_url'][ $i ]; $gallery_data['image_desc'][] = $_post['gallery']['image_desc'][ $i ]; } }
is there way simplify this? thx!
Comments
Post a Comment