Created
November 16, 2017 18:26
-
-
Save FriendlyWP/f418da67f59ad83f823cb5da055bd8e2 to your computer and use it in GitHub Desktop.
get_all_custom_field_meta issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"key": "group_5a0cb501d0249", | |
"title": "Location & Hours", | |
"fields": [ | |
{ | |
"key": "field_5a0cb50f1fae4", | |
"label": "Header Hours & Location info", | |
"name": "header_hours", | |
"type": "wysiwyg", | |
"instructions": "", | |
"required": 0, | |
"conditional_logic": 0, | |
"wrapper": { | |
"width": "", | |
"class": "", | |
"id": "" | |
}, | |
"default_value": "(631) 668-3377 | LOCATION | HOURS: Mon-Tues: 10-6; Wed-Thurs-Fri: 10-8; Sat: 10-5; Sun: 1-5", | |
"tabs": "all", | |
"toolbar": "basic", | |
"media_upload": 0, | |
"delay": 0 | |
} | |
], | |
"location": [ | |
[ | |
{ | |
"param": "options_page", | |
"operator": "==", | |
"value": "acf-options-copyright-address" | |
} | |
], | |
[ | |
{ | |
"param": "page_template", | |
"operator": "==", | |
"value": "default" | |
} | |
] | |
], | |
"menu_order": 0, | |
"position": "normal", | |
"style": "default", | |
"label_placement": "top", | |
"instruction_placement": "label", | |
"hide_on_screen": "", | |
"active": 1, | |
"description": "", | |
"modified": 1510785689 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// FOR TESTING THIS CODE IS ON MY PAGE.PHP TEMPLATE | |
// These both correct return the value of the header_hours field, which is a WYSIWYG field with text in it | |
echo get_field('header_hours'); | |
echo get_post_meta( get_the_ID(), 'header_hours', true ); | |
// Value of hte header_hours field: | |
(631) 668-3377 | LOCATION | HOURS: Mon-Tues: 10-6; Wed-Thurs-Fri: 10-8; Sat: 10-5; Sun: 1-5 | |
// See attached json for original file | |
$field_group_json = 'group_5a0cb501d0249.json'; | |
$field_group_array = json_decode( file_get_contents( get_stylesheet_directory_uri() . '/acf-json/' . $field_group_json ), true ); | |
$config = $field_group_array['fields']; | |
var_dump($config); | |
// Results of var_dump($config): | |
array (size=1) | |
0 => | |
array (size=13) | |
'key' => string 'field_5a0cb50f1fae4' (length=19) | |
'label' => string 'Header Hours & Location info' (length=28) | |
'name' => string 'header_hours' (length=12) | |
'type' => string 'wysiwyg' (length=7) | |
'instructions' => string '' (length=0) | |
'required' => int 0 | |
'conditional_logic' => int 0 | |
'wrapper' => | |
array (size=3) | |
'width' => string '' (length=0) | |
'class' => string '' (length=0) | |
'id' => string '' (length=0) | |
'default_value' => string '(631) 668-3377 | LOCATION | HOURS: Mon-Tues: 10-6; Wed-Thurs-Fri: 10-8; Sat: 10-5; Sun: 1-5' (length=91) | |
'tabs' => string 'all' (length=3) | |
'toolbar' => string 'basic' (length=5) | |
'media_upload' => int 0 | |
'delay' => int 0 | |
// This is the line that results in the error (below): | |
$acf_option_values = get_all_custom_field_meta( get_the_ID(), $config); | |
// ERROR MESSAGE | |
Catchable fatal error: Argument 1 passed to TimJensen\ACF\Field_Group_Values::get_field_value() must be an instance of TimJensen\ACF\string, string given, | |
called in C:\Users\Michelle\Documents\Websites\sitename.dev\wp-content\plugins\acf-field-group-values-master\src\Field_Group_Values.php on line 78 | |
and defined in C:\Users\Michelle\Documents\Websites\sitename.dev\wp-content\plugins\acf-field-group-values-master\src\Field_Group_Values.php on line 155 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Michelle, thanks for the detailed information. It seems that you must be running a PHP version lower than 7, is that correct? If you cannot upgrade to PHP 7 then please use the function here https://gist.github.com/timothyjensen/eec64d73f2a44d8b38a078e05abfad4b.
Let me know how it goes.