WordPress.org

Support

Support » Themes and Templates » Can't correct syntax error in WP editor

Can't correct syntax error in WP editor

  • wperic
    Participant

    @wperic

    Is this a bug:

    I’m trying to build a new function in my child theme functions.php. When something wasn’t right, I got an error message in the browser:

    Parse error: syntax error, unexpected ‘{‘ in /webroot/r/e/resea005/lynunderwood/www/wp-content/themes/veryplaintxt_child/functions.php on line 9.

    There weren’t any syntax errors. When I copied the function to a simple php file it ran fine. And there wasn’t any ‘{‘ in line 9. (As nearly as I can tell–WP editor doesn’t show line numbers.)

    But what really got me is that the editor wouldn’t let me correct it. I even tried deleting the entire function and still got the same syntax error message. I had to go to my webhosting site and manually remove the function there–none of the changes I had tried to make ever got saved.

    How does one correct a syntax error in the WP editor if WP doesn’t even let you save the corrected code?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • wperic
    Participant

    @wperic

    Here’s what seems to be causing the error–code that runs perfectly well until I insert it into WP:

    function category_art() {
        echo '<div id="category_art">';
        echo "<p>This is category_art div.</p>";
        echo '<br />';
        //$cat_title = single_cat_title();
        $cat_title = 'the arts';
        echo $cat_title;
    
        if ($cat_title == 'the arts' {
       $thePic = "http://www.theSite/wp-content/uploads/brusheslynnunderwood-500x711.jpg";
    }
    ....
    }

    Why would it be complaining about an unexpected ‘{‘? All my brackets are properly paired.

    Thanks

    wperic
    Participant

    @wperic

    Oops–missing a closing paren! Sorry.
    Still wondering tho about not being able to fix code in the WP editor.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can't correct syntax error in WP editor’ is closed to new replies.