Title: Warning: Uninitialized string offset 0
Last modified: January 8, 2023

---

# Warning: Uninitialized string offset 0

 *  Resolved [termi](https://wordpress.org/support/users/termi/)
 * (@termi)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/warning-uninitialized-string-offset-0/)
 * I created function that hoocks in to header of page to get ids of products on
   taxonomy page
 *     ```wp-block-code
       function woocommerce_acf_head_insert() {
       		$ids_list = array(0,0);
       		$count = 0;
       		while(have_posts() and $count < 2){
       		the_post();
       		$tmp = get_the_ID();  $ids_list[$count] = $tmp; $count += 1;	 }
   
       		// Sort array from lowest to highest
       		sort($ids_list);
       		echo $ids_list[0] . " " . $ids_list[1];
   
       			$value = get_field("resolution", $ids_list[0]); 
       			echo $value; 
   
   
       		if(!empty($ids_list[0])){
       		$value = get_field("resolution", $ids_list[1]); 
       		echo $value; 
       		}
       	} 
       ```
   
 * Then i want to register function to create short code to use this ids extracted
   with function in header to call ACF custom field of “x product” wher x is number
   in array of extracted ids
 *     ```wp-block-code
       add_shortcode( 'acf_field', 'woocommerce_acf_shortcode' );
   
       function woocommerce_acf_shortcode( $atts, $ids_list) {
         $atts = shortcode_atts( array(
           'field_name' => '',
           'cont' => '',
         ), $atts, 'the_field' );
   
         $field_name = $atts['field_name'];
         $cont = $atts['cont'];
         $id = $ids_list[$cont];
         ob_start();
         echo $id;
         the_field( $field_name, $id );
         return ob_get_clean();
       }
       ```
   
 * I use short code [acf_field field_name=”waterproof” cont=”0″] But i get warning:**
   Warning**: Uninitialized string offset 0 in **\public\wp-content\plugins\Woocomerce
   ACF\Woocomerce ACF.php** on line **310**
   In line 310 is:
 *     ```wp-block-code
         $id = $ids_list[$cont];
       ```
   
    -  This topic was modified 3 years, 5 months ago by [termi](https://wordpress.org/support/users/termi/).

Viewing 1 replies (of 1 total)

 *  [xue28 (woo-hc)](https://wordpress.org/support/users/xue28/)
 * (@xue28)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/warning-uninitialized-string-offset-0/#post-16356699)
 * Hi [@termi](https://wordpress.org/support/users/termi/)
 * Thanks for reaching out!
 * The error log points to the [Advanced Custom Fields for WordPress](https://www.advancedcustomfields.com/)
   plugin.
 * Since this is a third-party plugin which we don’t provide support for (please
   see our [Support Policy](https://woocommerce.com/support-policy/) here), it would
   be best reaching out to the plugin’s developers for further assistance here.
 * [https://www.advancedcustomfields.com/support/](https://www.advancedcustomfields.com/support/)
 * All the best and hopefully, the issue will be fixed soon.
 * Thanks!

Viewing 1 replies (of 1 total)

The topic ‘Warning: Uninitialized string offset 0’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [xue28 (woo-hc)](https://wordpress.org/support/users/xue28/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/warning-uninitialized-string-offset-0/#post-16356699)
 * Status: resolved