Support » Fixing WordPress » Keep getting unexpected '}'

  • I’m now on to trying to create a custom widget that displays post from a specific category. It’s basically like one I’ve seen before and I modeled the code after it. That being said, I keep getting the following error: “Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\wordpress\wp-content\themes\sports\tools\categorywidget.php on line 68”.

    Here’s the entire code:

    [ Code moved into pastebin below. For more than 10 lines of code please remember to use in future. ]

    Any idea on what went wrong? Thanks in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator cubecolour



    The error message refers to an unexpected closing brace on line 68.

    Line 68 is

    <?php } ?>

    I can’t see a corresponding opening brace, so it looks like that line might be superfluous, so that’s the first thing I would look at.

    According to Notepad++, the corresponding brace goes back to line 19:

    function widget($args, $instance) {

    Also, I tried deleting line 68 and I get the same error further on down with this one (line 94):
    <?php } ?>

    Then when I delete that, I get the whole unexpected $end.

    Hope that’s specific enough.

    I have a suspicion that the real problem lies else where given that this is my second effort at creating said widget and I got the same errors. I’m still very new to this, so I may be wrong.



    Forum Moderator

    the two if ( have_posts() ) : started in line 26 and line 56 are not closed with an endif;

    I changed the endwhile;’s to endif;’s but I get an unexpected endif error.



    Forum Moderator

    I changed the endwhile;’s to endif;’s


    just add the endif; after the endwhile;

    Okay, did that, but now I’m getting this error: “Parse error: syntax error, unexpected ‘;’, expecting T_FUNCTION in C:\xampp\htdocs\wordpress\wp-content\themes\sports\tools\categorywidget.php on line 70”.

    However, there is no ‘;’ on line 70. Just “<?php } ?>”.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Keep getting unexpected '}'’ is closed to new replies.