PHP string inside get_post_thumbnail_id

This is my first time I'm using WMPU for help. I'm making a custom theme so I don't know if I'm in the right place.

I don't know if this a WordPress bug or not but my website doesn't recognize $post->ID. So I have a string that stores the post ID but I don't know how to execute that string inside wp_get_attachment_image_src?

The String: <?php $currentID = $post->ID;?>

The code: <?php echo wp_get_attachment_image_src( get_post_thumbnail_id('$currentID'), 'small-post' )[0]; ?>

Am I doing this right or is there another way?


  • Nithin
    • Support Wizard

    Hi Gregory,

    Hope you are doing good today. :slight_smile:

    <?php echo wp_get_attachment_image_src( get_post_thumbnail_id('$currentID'), 'small-post' )[0]; ?>

    I could see there is a quote added for $currentID, maybe that is the problem here:

    <?php echo wp_get_attachment_image_src( get_post_thumbnail_id($currentID), 'small-post' ); ?>

    Please let us know if you need any further assistance, have a nice weekend. :slight_smile:

    Kind Regards,

  • Gregory
    • Site Builder, Child of Zeus

    Didn't work. Takes the image from the last post on the page and repeats them on every post that has that image. I can see the image is there but is overrun. Going to go the javascript route with replace text at broswer.width.

    Thanks for the help.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.