Title: Error in class.cooked-shortcodes.php
Last modified: March 17, 2025

---

# Error in class.cooked-shortcodes.php

 *  Resolved [Braian Menkhoff](https://wordpress.org/support/users/bihush/)
 * (@bihush)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/error-in-class-cooked-shortcodes-php/)
 * Hi,
 * I’m getting this error in my error log:
 * Trying to access array offset on value of type bool plugins/cooked/includes/class.
   cooked-shortcodes.php on line 378
 * What can be the issue?

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

 *  Thread Starter [Braian Menkhoff](https://wordpress.org/support/users/bihush/)
 * (@bihush)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/error-in-class-cooked-shortcodes-php/#post-18364794)
 * I’m guessing that if there is no image in a recipes gallery it returns the php
   warning!
 *  Plugin Author [XjSv](https://wordpress.org/support/users/xjsv/)
 * (@xjsv)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/error-in-class-cooked-shortcodes-php/#post-18365783)
 * Hello [@bihush](https://wordpress.org/support/users/bihush/), There is a check
   in the code to check if the gallery is empty and if so it does not attempt to
   load any files.
 * I also just did a test right now to see if a recipe with no gallery images causes
   a error but I did not see anything.
 * Could you link the recipe in question so I can take a look? Maybe there is a 
   clue as to whats going on.
 *  Thread Starter [Braian Menkhoff](https://wordpress.org/support/users/bihush/)
 * (@bihush)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/error-in-class-cooked-shortcodes-php/#post-18366305)
 * There is no specific recipe! That php warning is in my error-log
 * I did this tweak in my local, it seems like solved the issue but do you think
   it’s a good approach? I have large amount of recipes I wanna make sure, before
   going online with this fix
 *     ```wp-block-code
       if ( isset($gallery_items) && !empty($gallery_items) ):    foreach( $gallery_items as $item ):        $image_src = wp_get_attachment_image_src( $item, [900, 900] );        $image_title = get_the_title( $item );        if ( is_array($image_src) && isset($image_src[0]) ) {            $gallery_html .= '<a href="' . esc_url( $image_src[0] ) . '" data-alt="'.esc_attr( $image_title ).'" data-caption="'.esc_attr( $image_title ).'">                <img alt="'.esc_attr( $image_title ).'" src="' . wp_get_attachment_image_url( $item, 'thumbnail' ) . '" />            </a>';        }    endforeach; endif;
       ```
   
 *  Plugin Author [XjSv](https://wordpress.org/support/users/xjsv/)
 * (@xjsv)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/error-in-class-cooked-shortcodes-php/#post-18366341)
 * Interesting, because “!empty($gallery_items)” should have not allowed the loop
   if the array is empty. But I can see how it could possibly lead to this.
 * Thank you for that, I will add this to the source code so that when the next 
   update comes out you don’t loose any functionality.
 *  Thread Starter [Braian Menkhoff](https://wordpress.org/support/users/bihush/)
 * (@bihush)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/error-in-class-cooked-shortcodes-php/#post-18366349)
 * Thank you 🙏
 *  Plugin Author [XjSv](https://wordpress.org/support/users/xjsv/)
 * (@xjsv)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/error-in-class-cooked-shortcodes-php/#post-18366358)
 * My pleasure.

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

The topic ‘Error in class.cooked-shortcodes.php’ is closed to new replies.

 * ![](https://ps.w.org/cooked/assets/icon-256x256.png?rev=2005204)
 * [Cooked - Recipe Management](https://wordpress.org/plugins/cooked/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cooked/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cooked/)
 * [Active Topics](https://wordpress.org/support/plugin/cooked/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cooked/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cooked/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [XjSv](https://wordpress.org/support/users/xjsv/)
 * Last activity: [1 year, 2 months ago](https://wordpress.org/support/topic/error-in-class-cooked-shortcodes-php/#post-18366358)
 * Status: resolved