Title: Error on function or do_shortcode
Last modified: August 21, 2016

---

# Error on function or do_shortcode

 *  Resolved [paer](https://wordpress.org/support/users/paer/)
 * (@paer)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/)
 * I tried to add a the function `get_image_credits();` on a post, but I got this
   message:
 * > Fatal error: Call to undefined function get_image_credits() in /…/wp-content/
   > themes/…/content-meta.php on line 9
 * Later I tried `do_shortcode('[image-credits]')` and it worked, but I got this
   error message as well:
 * > Warning: Wrong parameter count for in_array() in /…/wp-content/plugins/image-
   > credits/plugin.php on line 137
 * Does anyone have an idea to fix this?
 * [http://wordpress.org/extend/plugins/image-credits/](http://wordpress.org/extend/plugins/image-credits/)

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

 *  Thread Starter [paer](https://wordpress.org/support/users/paer/)
 * (@paer)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822369)
 * I’m still lost with this problem. Does anyone else experience the same problems?
 *  Thread Starter [paer](https://wordpress.org/support/users/paer/)
 * (@paer)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822383)
 * I found a simple solution, but only works by using do_shortcode:
    `<?php echo
   do_shortcode('[image-credits]') ?>`
 * Just exclude “in_array” On line 137 of file plugin.php. See example:
 * `if ( !empty( $source_name ) && !empty( $source_url ) /*&& !in_array( $source_url,
   $source_urls )*/ ) {`
 * Until now, I haven’t discovered any bugs yet. Fingers crossed 😉
 *  [thatwastaxing](https://wordpress.org/support/users/thatwastaxing/)
 * (@thatwastaxing)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822397)
 * I have this problem too:
 * `Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\
   htdocs\testsite\wp-content\plugins\image-credits\plugin.php on line 137`
 *  Thread Starter [paer](https://wordpress.org/support/users/paer/)
 * (@paer)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822398)
 * Did u comment this out yet?
 * `/*&& !in_array( $source_url, $source_urls )*/`
 *  [thatwastaxing](https://wordpress.org/support/users/thatwastaxing/)
 * (@thatwastaxing)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822399)
 * No because I needed the shortcode and not put inside the theme. But I just tried
   it (deleted, not commented out) and it works with the shortcode too! Thanks!
 *  [jeremy9856](https://wordpress.org/support/users/jeremy9856/)
 * (@jeremy9856)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822410)
 * This warning is very simple to fix
 * `Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\
   htdocs\testsite\wp-content\plugins\image-credits\plugin.php on line 137`
 * At the line 137 add just this :
    `$source_urls = array();`
 * Before that :
 * `if ( !empty( $source_name ) && !empty( $source_url ) && !in_array( $source_url,
   $source_urls ) ) {`
 *  Thread Starter [paer](https://wordpress.org/support/users/paer/)
 * (@paer)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822411)
 * Thank you, this fix did it.
 * But after fixing the issue on line 137, I had the same issue on line 117, too.
 * So I added this:
    `$attachment_ids = array();`
 * Before that:
    `if ( in_array( $id, $attachment_ids ) )`
 *  [thatwastaxing](https://wordpress.org/support/users/thatwastaxing/)
 * (@thatwastaxing)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822413)
 * I applied your code but now only one image credit shows up in a post where there
   is more than one image that has credits.
 *  Plugin Author [Adam Capriola](https://wordpress.org/support/users/adamcapriola/)
 * (@adamcapriola)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822414)
 * This array error will be fixed in an update to the plugin I’m uploading later
   today.

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

The topic ‘Error on function or do_shortcode’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/image-credits_ffffff.svg)
 * [Image Credits](https://wordpress.org/plugins/image-credits/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/image-credits/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/image-credits/)
 * [Active Topics](https://wordpress.org/support/plugin/image-credits/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/image-credits/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/image-credits/reviews/)

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 9 replies
 * 4 participants
 * Last reply from: [Adam Capriola](https://wordpress.org/support/users/adamcapriola/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/error-on-function-or-do_shortcode/#post-3822414)
 * Status: resolved