0

Im trying to get the id of images from a post. i've tried with wp_get_attachment_url( $id ) and some other options but always get an empty array when i do var_dump or print_r. Whats the correct way to do it? thanks.

1

If it is post-thumbnail, it will return the ID:-

<?php $post_thumbnail_id = get_post_thumbnail_id( $post_id ); ?> 

try this.

  • thanks for your answer, but i want to get the id from images inside the content. Imagine i put 4 images in that post i want to be able to access them dynamically by their id. – user117473 Apr 12 '17 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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