Title: Function get_video_url() is referencing non-existent array offset.
Last modified: August 20, 2016

---

# Function get_video_url() is referencing non-existent array offset.

 *  Resolved [Dan Rossiter](https://wordpress.org/support/users/danrossiter/)
 * (@danrossiter)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/function-get_video_url-is-referencing-non-existent-array-offset/)
 * When I run with debugging, I’m getting two Notices from `amt_get_video_url()`:
 *     ```
       Notice: Undefined offset: 1 in /path/to/wp-content/plugins/add-meta-tags/add-meta-tags.php on line 842
   
       Notice: Undefined offset: 1 in /path/to/wp-content/plugins/add-meta-tags/add-meta-tags.php on line 850
       ```
   
 * If you just check whether any matches exist before making assignments with `$
   matches[1]`, this should be resolved. Here’s one option for a fix:
 *     ```
       function amt_get_video_url() {
           global $post;
   
           // Youtube
           $pattern = '#youtube.com/watch\?v=([-|~_0-9A-Za-z]+)#';
           if( preg_match($pattern, $post->post_content, $matches) ){
               return 'http://youtube.com/v/' . $matches[1];
           }
   
           // Vimeo
           $pattern = '#vimeo.com/([-|~_0-9A-Za-z]+)#';
           if( preg_match($pattern, $post->post_content, $matches) ){
               return 'http://vimeo.com/couchmode/' . $matches[1];
           }
   
           return '';
       }
       ```
   
 * All the best!
    -Dan
 * [http://wordpress.org/extend/plugins/add-meta-tags/](http://wordpress.org/extend/plugins/add-meta-tags/)

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

 *  Plugin Author [George Notaras](https://wordpress.org/support/users/gnotaras/)
 * (@gnotaras)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/function-get_video_url-is-referencing-non-existent-array-offset/#post-3357989)
 * [@dan](https://wordpress.org/support/users/dan/): Thank you for your feedback.
   Will be fixed in 2.1.0.
 *  Plugin Author [George Notaras](https://wordpress.org/support/users/gnotaras/)
 * (@gnotaras)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/function-get_video_url-is-referencing-non-existent-array-offset/#post-3357993)
 * Fixed in 2.1.0 using provided code. Thanks again.
 *  Thread Starter [Dan Rossiter](https://wordpress.org/support/users/danrossiter/)
 * (@danrossiter)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/function-get_video_url-is-referencing-non-existent-array-offset/#post-3357999)
 * Thanks, George! Great plugin, btw! Definitely a SEO must-have!

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

The topic ‘Function get_video_url() is referencing non-existent array offset.’ is
closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/add-meta-tags.svg)
 * [Add Meta Tags](https://wordpress.org/plugins/add-meta-tags/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/add-meta-tags/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/add-meta-tags/)
 * [Active Topics](https://wordpress.org/support/plugin/add-meta-tags/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/add-meta-tags/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/add-meta-tags/reviews/)

## Tags

 * [notice](https://wordpress.org/support/topic-tag/notice/)
 * [quick fix](https://wordpress.org/support/topic-tag/quick-fix/)

 * 3 replies
 * 2 participants
 * Last reply from: [Dan Rossiter](https://wordpress.org/support/users/danrossiter/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/function-get_video_url-is-referencing-non-existent-array-offset/#post-3357999)
 * Status: resolved