Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using a custom post type plugin that returns an uploaded file's attachment ID instead of its url. I've been able to get the image to display using wp_get_attachment_image_src as outlined in the codex here http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src but my problem is getting it to play nicely with the code on the template page used to call the information from the custom post type set up using the [WCK Custom Fields Creator][1] plugin.

Stripping it down to the basics, this is what calls the custom post type info from the template page:

<?php 
    $slideshowplatform = get_post_meta($post->ID, 'slideshowplatform', true);
    foreach($slideshowplatform as $slide) {
        echo '<img src="' . $slide['slide'] . '" />';
    }
?>

I'm having difficulty reconciling this with what the codex provides:

<?php 
    $attachment_id = 8; // attachment ID
    $image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array
?>

<img src="<?php echo $image_attributes[0]; ?>">

It seems like something like the following should work, but I'm obviously missing something with the php syntax

<?php 
    $slideshowplatform = get_post_meta($post->ID, 'slideshowplatform', true);
    foreach($slideshowplatform as $slide) {
        $image_attributes = wp_get_attachment_image_src( $slide['slide'] );
        echo '<img src="<?php echo $image_attributes[0]; ?>" />';
    }
 ?>

Any thoughts would be appreciated, thanks.

share|improve this question
add comment

1 Answer 1

Too many echos. This:

echo '<img src="<?php echo $image_attributes[0]; ?>" />';

Should be this:

echo '<img src="' . $image_attributes[0] . '" />';
share|improve this answer
    
Thank you, that did it. Much obliged. –  Travis Fulton Jun 25 '12 at 18:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.