• peachesandguacamole

    (@peachesandguacamole)


    Hi all.
    Hoping you can help.

    I added some code to the functions.php file but on updating the file in WordPress I just get the error message:
    Parse error: syntax error, unexpected ‘<‘ in functions.php on line 28

    I’ve deleted the code I entered and tried to resave and I still get the same error.

    I’ve also deleted the file through FTP and replaced it with a backup version of the file and still the error message remains. The whole site isn’t displaying and it looks like WordPress must have automatically edited some code elsewhere as replacing the file with the backup version still doesn’t help.

    Can anyone shed any light on this bizarre situation?

Viewing 4 replies - 1 through 4 (of 4 total)
  • First make sure that the backup does not have the same problem and is being restored correctly i.e it uploads and replaces the problematic file.

    There seems to be a problem with your opening and closing PHP tags: <?php and ?>. Most common problem is missing a closing PHP tag and writing HTML next to it. Start looking for the problem around line 28 as stated by the error.

    Thread Starter peachesandguacamole

    (@peachesandguacamole)

    Thanks.
    I’m stumped, line 28 doesn’t even exist.
    it finishes on line 26.

    Line 28 was the first line of the new code I entered, but for some reason replacing it with the backed up functions.php file isn’t fixing the problem.

    I’m using Cyberduck FTP to put the files back, and it’s in the child theme folder.
    is it possible WP has made edits elsewhere?

    here’s the contents of the functions.php file

    <?php

    // =============================================================================
    // FUNCTIONS.PHP
    // —————————————————————————–
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================

    // =============================================================================
    // TABLE OF CONTENTS
    // —————————————————————————–
    // 01. Enqueue Parent Stylesheet
    // 02. Additional Functions
    // =============================================================================

    // Enqueue Parent Stylesheet
    // =============================================================================

    add_filter( ‘x_enqueue_parent_stylesheet’, ‘__return_true’ );

    // Additional Functions
    // =============================================================================

    It’s highly unlikely that WP will make file changes unless you or the theme coded it to do so. Do you still have the piece of code that you added?

    Also, can you try downloading the functions.php file from your FTP and see if the code you added has really been removed? If the content is the same like what you posted then it might be referring to the functions.php file of your parent theme, so you can check that as well.

    Did you ever figure out how to fix this? I’m having the same issue–I replaced the file with a fresh one a number of times. Getting the same syntax error for a line that doesn’t exist.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Parse Error in functions.php’ is closed to new replies.