-1

I've added some php code to my functions.php child theme, but getting the following error message:

Parse error: syntax error, unexpected ' ' (T_STRING) in functions.php

I've been staring at the code for too long now and can't see what I'm doing wrong:

add_filter( 'pt_cv_fields_html', 'cvp_theme_other_fields_in_title', 100, 2 );
function cvp_theme_other_fields_in_title( $args, $post ) {
    global $pt_cv_id;
    if ( in_array( $pt_cv_id, array( 'e3cd1844un', '60d308bw40' ) ) ) {
        if ( isset( $args[ 'custom-fields' ] ) ) {
            $args[ 'title' ] = preg_replace( '/(<\/a>)/', ' ' . strip_tags( $args[ 'custom-fields' ] ) . '$1', $args[ 'title' ] );
            unset( $args[ 'custom-fields' ] );
        }
    }
    return $args;
}
ADyson
  • 57,178
  • 14
  • 51
  • 63
danniee
  • 29
  • 5
  • Unfortunately no. I'm new to php and received a lot of help writing this code. Really struggling to find the issue. – danniee Oct 29 '20 at 11:29

1 Answers1

0

Actually, there was nothing wrong with the code. Turns out that when I copy paste it from my email client, it must do something to the code. When I copy paste it from here, then it works. I don't get it, but at least it works!

danniee
  • 29
  • 5
  • In that case it's likely that your email client uses a different ASCII/UNICODE representation of the white space than Stack Overflow and that your IDE doesn't recognise the email one. Similar things happen with apostrophes, see `´` vs `'`. – Adriaan Oct 29 '20 at 11:43
  • Ah ok, that makes perfect sense! Thank you sir for explaining. You learn something new every day haha. Wishing you a good day. – danniee Oct 29 '20 at 11:56