Fatal Error When Updating PHP
-
Hey,
So, I needed a relationship custom field meta value in a macro couple years ago and you guys helped me a lot with a function in this topic -> Custom Relationship Field Macro | WordPress.org.
This is working fine, but site crashes when I try to update its PHP to anything after 8 (it is currently 7.4). I get “PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string” on line 10 of this code (I bolded line 10):
add_action( 'smartcrawl_known_macros', function( $replacements ){
global $post;
$pods_field_slug = "artist"; // please adjust based on your relationship field's actual slug
$value = get_post_meta($post->ID, $pods_field_slug, true);
$replacements['%%pods_relationship_id%%'] = $value['ID'];
$replacements['%%pods_relationship_title%%'] = $value['post_title'];
return $replacements;
} );P.S.: I changed yours ‘wds-known_macros’ for ‘smartcrawl_known_macros’ because there was some “deprecated” warning; I was having the problem before that change, obviously.
The topic ‘Fatal Error When Updating PHP’ is closed to new replies.