Help - how do I legally nest PHP?

by Mrs S
1 replies
Can anyone help - I've literally been googling for about 5 hours and can't figure this out.

I want to take the output of the first php statement (which outputs an attachment id for an image) and use it to replace the XX in the second statement (if I put the attachment id in there it displays the image).

But I don't know how to legally nest php

Can anyone save my sanity??

<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'hh-product-image', true);
?>

<?php echo wp_get_attachment_image( XX ); ?>
#legally #nest #php
  • Profile picture of the author Havenhood
    <?php
    global $wp_query;
    $postid = $wp_query->post->ID;
    $output = get_post_meta($postid, 'hh-product-image', true);
    ?>

    <?php echo wp_get_attachment_image( $output ); ?>

    or

    <?php
    global $wp_query;
    $postid = $wp_query->post->ID;

    ?>

    <?php echo wp_get_attachment_image( get_post_meta($postid, 'hh-product-image', true) ); ?>

    Did I understand you correctly?
    Signature

    --= -Spazzle- =--

    {{ DiscussionBoard.errors[3112266].message }}

Trending Topics