I have one template file for the main page, after creating home page I have added text to check if it reflect changes on my home page or not and it was successfully displaying text. But when I try to add image by clicking on add media option then image is uploaded but not displaying on my page. What piece of code should be used to get this image on my template file or any other suggestions?
if You wish to display an image, which is a thumbnail of a post, then use:
<?php echo get_the_post_thumbnail( $pageID, 'thumbnail' ); ?>
if You wish to display an image from media, then use
<?php echo wp_get_attachment_image( $attachmentID, 'thumbnail' ); ?>
thumbnail is set for size and is set by default. Size can be changed to medium,large or full
if You want to display a specific image, just insert the img tag
There are more ways, this are the basic ones, which are enough. Good luck
you can add any custom field with this module https://wordpress.org/plugins/advanced-custom-fields/. And can easily add it to your pages and posts.