1

So I have wasted 5 hours of my life to figure how to fetch wordpress custom post videos and been unsuccessful and here i am. Looking for expert advice.

My Requirement: - Fetch all video attachments of a custom post. - Display all videos url in frontend by a foreach loop with the post ID with custom html and css.

What I did:

- Everything
- get_attached_media('video', $post_ID); // didn't work
- wp_query(.. with arguements) //didn't work
- get_post(with argument on post_type=attachment and post_parent = $post_id) // didn't work
-get_children (with argument on post_type=attachment and post_parent = $post_id) // didn't work

What i get : - Image can be retrived but not videos..

Help me understand how it is done?

  • 1
    And you are sure you spelled video correctly? – cjbj May 30 '18 at 7:33
  • Are the video URL's being added as custom field(s)? If so, are you using wordpress custom fields or ACF? – wharfdale May 30 '18 at 9:08
  • Are you certain the videos are attached to the post? Just using the video somewhere in the post isn't enough to be 'attached'. To be attached the video has to have been uploaded directly to that post. – Jacob Peattie May 30 '18 at 10:50
  • Yea i added from Add Media button. Just like i added image. I an get the image but not the video. The video is added dirctly on the editor via add media no custom field used. – Genius in trouble May 31 '18 at 9:54

Your Answer

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

Browse other questions tagged or ask your own question.