WordPress.org

Ready to get started?Download WordPress

Forums

Keep getting unexpected '}' (8 posts)

  1. ArenaPigskin
    Member
    Posted 1 year ago #

    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 pastebin.com in future. ]

    http://pastebin.com/y4qxSNhQ

    Any idea on what went wrong? Thanks in advance.

  2. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 1 year ago #

    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.

  3. ArenaPigskin
    Member
    Posted 1 year ago #

    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.

  4. ArenaPigskin
    Member
    Posted 1 year ago #

    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.

  5. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

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

  6. ArenaPigskin
    Member
    Posted 1 year ago #

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

  7. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

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

    why?

    just add the endif; after the endwhile;

  8. ArenaPigskin
    Member
    Posted 1 year ago #

    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 } ?>".

Topic Closed

This topic has been closed to new replies.

About this Topic