• Resolved junkes

    (@junkes)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Jair – WPMU DEV Support

    (@wpmudevsupport15)

    Hello @junkes

    The code we provided back then is almost 4 years old, and the functions it uses may not be compatible with the current, supported PHP versions. I’m afraid that creating or fixing this code will be outside the scope of support we can provide here. To fix that, you’ll need to hire a developer to provide the required custom code for you. WordPress provides a jobs directory here https://jobs.wordpress.net/

    If you need further advice about it, feel free to email wpsupport@incsub.com with this subject:
    ATTN: WPMU DEV support – wp.org

    Kind regards,
    Jair.

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @junkes

    We haven’t heard from you in a while, I’ll go and mark this thread as resolved. If you have any additional questions or require further help, please let us know!

    Best Regards
    Patrick Freitas

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

The topic ‘Fatal Error When Updating PHP’ is closed to new replies.