im creating a custom theme for wordpress 4.1.1.

i had encounter a problem with adding a media (an image) to a post.

When I choose an image via the media library, i select it but i only have the choice to insert it into the post.

I know that it's possible to retrieve the image source with "wp_get_attachment_image_src" function so i guess my question if there's a way to link the image without posting it ?

Here's what im trying to do :

<?php while(have_posts()) : the_post;?> 
     <div class="oeuvre">
         <img class="img-oeuvre" src="<?php //should be something dynamic like the_image() ;?>" alt=""/>
         <div class="infos-oeuvre">
             <p><?php the_title(); ?></p>
             <p><?php the_content() ; ?></p>
             <a class="btn-oeuvre "ref="http://www.thisiscolossal.com/2014/05/photographer-laurent-lavender-plays-with-the-moon/" target="_blank">plus d'infos</a>
<?php endwhile; ?>

I'm not posting to have the solution (but feel free to give it if you want to XD) but i'm asking myself if i have the right approach to this issue.

If not, any advice, link or example are welcome !


By default an image belongs only to one post. Indeed that post is the parent post of the attachments (that are posts too). I think that the comment by TheDeadMedic is very good option because it is native to WordPress, but you can only link a post with one Featured Image. If you want to attach several files you can use the plugin WP Better Attachments (link).

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.