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="" 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 !

Read more here: Custom theme - how to link the image without posting it


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: