• My code works perfectly fine until I enclose it in a function. Variables can pass into the function just fine and when I echo them I can see they work. But none of these functions work anymore:

    get_the_ID();
    wp_get_attachment_image($image->ID, ‘thumbnail’);
    wp_get_attachment_image_src($image->ID, array(150, 150));

    Am I not allowed to put the loop inside of my own function? Once I remove the function it works as before. It seems to not be able to scope the vars properly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Sorry, is this Jquery?
    If so,
    Substitute $=JQuery

    Thread Starter joeljoelbinks

    (@joeljoelbinks)

    No, just a php var

    I found a way to work around it. Unfortunately I couldn’t use get_the_ID() or the $image->ID value. At any rate, it works now. Not sure I’m liking WordPress.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘get_the_ID() get get_attachment_image() fail inside function’ is closed to new replies.