You can’t use get_custom_field or print_custom_field when in a loop like that because the context of the variables: those functions are meant for the single-page templates only.
When looping over values in a case like this, the task becomes converting the post id (i.e. the asset id) into its src or url. You can use WP’s built-in functions for this, e.g. http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src : just pass it the id of the post in question. See updated example at https://code.google.com/p/wordpress-custom-content-type-manager/wiki/to_image_src_OutputFilter
I see. Thank You sir.
Actually I made it with custom query like this.
<?php
$loop = new WP_Query(array('post_type' => 'custom', 'posts_per_page' => -1));
?>
<div id="homeSlides" class="carousel slide" data-wrap="false">
<div class="carousel-inner">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<!-- Carousel items -->
<div class="item">
<img src="<?php print_custom_field('slideshow_img_one:to_image_src'); ?>" />
<img src="<?php print_custom_field('slideshow_img_two:to_image_src'); ?>" />
<div class="slide_content">
<h1 class="slide_title">
<?php the_title(); ?>
</h1>
<?php the_content();?>
</div>
</div>
<?php endwhile; ?>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#homeSlides" data-slide="prev">‹</a>
<a class="carousel-control right" href="#homeSlides" data-slide="next">›</a>
</div>
<?php wp_reset_query(); ?>
My mind explodes and my heart dies every time WP_Query uses global variables like that, but if it works, great!
🙂 Don’t scare me man, please!
I’m not developer and no developer friends around. So I fight alone.
I’m open for advices from real developers and more mindful persons – always. That is reason to post questions in forums like this.
🙂
Anyway You are one of this persons that always try to help other.
Regards
If your solution works for the problem, that’s great: that’s the most important thing. The immediate problem was solved.
WP isn’t really developer friendly in my opinion: it deserves massive recognition for bringing PHP to the masses, but the quality and structure of its code is sometimes painfully bad, and although I get flamed for saying things like that I think it’s good for users to know the limitations of the software they are using. In this case, the habit of WP of relying on global variables makes it difficult to see what’s going on with its code, and it can sometimes make the code less secure, and it usually makes the code less testable. So those can be real concerns in the longterm, but again, the immediate problem was solved, so you can take my reservations with a grain of salt.
I see.
Thank You again.
Best Regards.