Beschrijving
Nederlands
Forums / Code oplossingen gezocht / Get Attachment for Video
Get Attachment for Video
Hi guys,
There is a plugin that let’s me upload a title, description and image with a form.
If you send it, it creates and automatic post with the title, description and the image.
The code for showing the image is:
if ( has_post_thumbnail() && is_single() ) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); ?> <div class="attachments"> <p class="image-caption"> <?php _e('Ingezonden video:','feature-request'); ?> </p> <figure class="avfr-image post-image"> <?php echo '<a rel="lightbox" href="' . $large_image_url[0] . '" title="' . the_title_attribute( 'echo=0' ) . '">'; the_post_thumbnail( 'thumbnail' ); echo '</a>'; ?>I would like to rewrite the code so that I can upload a video and it automaticly posts the video , just like the image.
Can somebody help me with the code?
You can get the videos attached (uploaded) to a specific post with the following code:
`
$videos = get_attached_media( ‘video’, get_the_ID() );foreach ( $videos as $video ) {
var_dump( $video );
}
`For more information about the
get_attached_mediafunction see: https://codex.wordpress.org/Function_Reference/get_attached_media.
Het onderwerp ‘Get Attachment for Video’ is gesloten voor nieuwe reacties.
- In: Code oplossingen gezocht
- 1 reactie
- 2 deelnemers
- Laatste antwoord van: Remco Tolsma
- Laatste activiteit: 7 jaren, 11 maanden geleden
- Status: onopgelost



