I have to add image as attachment in post in wordpress. Currently image is set as a part of Post content but i have to display a attachment link in post so users can download that image via attachment link.
Thank you,
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you will always have only ONE image – it will be better to set it as “featured image” and then :
then
full code :
if you do not want to use featured image – the next function will get you always the FIRST image in a post
if you have more than one image the thing gets a little more complicated – and you will have to search for all attachments and loop through the array . (change ‘numberposts’ => -1, to get all)