Title: Multiple Custom Fields
Last modified: August 22, 2016

---

# Multiple Custom Fields

 *  [slice](https://wordpress.org/support/users/tamarasricehotmailcom/)
 * (@tamarasricehotmailcom)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-custom-fields-8/)
 * I’ve got a custom field that I let my users put video links into. I also let 
   them create multiple versions of the custom field if they want to have more than
   one video. I’m using get_video_thumbnail($post->ID) and it’s only returning one
   of the thumbnails. Is there a way to get multiple thumbnails back for multiple
   custom fields?
 * Thanks.
 * [https://wordpress.org/plugins/video-thumbnails/](https://wordpress.org/plugins/video-thumbnails/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [slice](https://wordpress.org/support/users/tamarasricehotmailcom/)
 * (@tamarasricehotmailcom)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-custom-fields-8/#post-5258431)
 * I probably shouldn’t have done this but I was able to get what I needed by exposing
   the get_first_thumbnail_url method. I just added the below code at the bottom
   of vidoe-thumbnails.php.
 * function get_first_thumbnail_url( $markup ) {
    global $video_thumbnails; return
   $video_thumbnails->get_first_thumbnail_url( $markup ); }
 * Then I pull the custom field value myself and just pass the above function the
   video’s URL.
 * Thanks for the plug-in. It works great. And if there’s a better way to do the
   above that doesn’t involve changing the plug-in source please let me know.
 *  Plugin Author [Sutherland Boswell](https://wordpress.org/support/users/sutherlandboswell/)
 * (@sutherlandboswell)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-custom-fields-8/#post-5258715)
 * The best solution for now (I may add the option for multiple custom fields in
   the future) is to add some code to your theme’s functions.php file or in [your own separate plugin](https://refactored.co/blog/getting-started-with-the-wordpress-plugin-api).
 * If it is the same custom field multiple times, use this:
 *     ```
       function custom_video_thumbnail_markup( $markup, $post_id ) {
       	$fields = get_post_meta( $post_id, 'my_custom_field', false );
       	foreach ( $fields as $field ) {
       		$markup .= ' ' . $field;
       	}
       	return $markup;
       }
   
       add_filter( 'video_thumbnail_markup', 'custom_video_thumbnail_markup', 10, 2 );
       ```
   
 * Be sure to replace `my_custom_field` with the name of your custom field.
 * If the custom fields have different names, use this:
 *     ```
       function custom_video_thumbnail_markup( $markup, $post_id ) {
           return get_post_meta( $post_id, 'first_custom_field', true ) . ' ' . get_post_meta( $post_id, 'second_custom_field', true );
       }
   
       add_filter( 'video_thumbnail_markup', 'custom_video_thumbnail_markup', 10, 2 );
       ```
   
 * In this case be sure to replace `first_custom_field` and `second_custom_field`
   with the names of your fields.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Multiple Custom Fields’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/video-thumbnails_3e6f7f.svg)
 * [Video Thumbnails](https://wordpress.org/plugins/video-thumbnails/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/video-thumbnails/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/video-thumbnails/)
 * [Active Topics](https://wordpress.org/support/plugin/video-thumbnails/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/video-thumbnails/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/video-thumbnails/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Sutherland Boswell](https://wordpress.org/support/users/sutherlandboswell/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-custom-fields-8/#post-5258715)
 * Status: not resolved