• I’m trying to figure out a global post-to-post navigational scheme and I haven’t a clue what I’m doing. I need help with a code snippet. I have it right below the content div in my index.php file. I’m getting a parse error, unexpected on the last ‘}’:

    if (basename(__FILE__) == 'index.php' && $_SERVER['QUERY_STRING'] =='') {
    previous_post('%','<img src="https://www.bbiverson.com/images/buttons/previous.jpg" alt="Read Previous Entry" align="middle" />Previous Entry', 'no', 'no', 1, '')
    } else {
    previous_post('%','<img src="https://www.bbiverson.com/images/buttons/previous.jpg" alt="Read Previous Entry" align="middle" />Previous Entry', 'no', 'no', 1, '') &nbsp; ?>
    ">Latest Entry &nbsp;
    <?php next_post('%','Next Entry<img src="https://www.bbiverson.com/images/buttons/next.jpg" alt="Read Next Entry" align="middle" />','no','no',1,'');
    }

    Can someone help me?

Viewing 10 replies - 1 through 10 (of 10 total)
  • What are those ” amp;nbsp;”s meant to be? The forum has mangled your code somewhat.
    And your error is “Unexpected }”?

    It looks like you’re missing a closing paranthesis for your primary IF statement. So put a close ‘)’ after ‘$_SERVER[‘QUERY_STRING’] ==”)’ and see if your error goes away.
    Regards

    You wanted what ?

    Thread Starter pezastic

    (@pezastic)

    The previous, latest, and next links were running together, so I put in a couple non-breaking spaces. Anyway, they aren’t the problem. I don’t know what is, but they aren’t. ??

    Actually, what I meant was:
    if (basename(__FILE__) == ‘index.php’) && ($_SERVER[‘QUERY_STRING’]) == ”)) {
    Notice the ‘)’ after the first check. With this code I don’t get any errors.
    Regards

    Send me an email and I’ll help you through this.
    Regards

    Scott Reilly

    (@coffee2code)

    WordPress & Plugin Developer

    To my eye it looks like the parentheses are unbalanced for the if()’s conditions. Perhaps try:
    if ((basename (__FILE__) == 'index.php') && ($_SERVER['QUERY_STRING'] == '')) {
    I haven’t look at this any deeper than that.

    Thread Starter pezastic

    (@pezastic)

    Nope that didn’t solve the error problem, either. ??

    Scott Reilly

    (@coffee2code)

    WordPress & Plugin Developer

    Do you close out the php tag at the end of your snippet, like so:
    <?php next_post('%','Next Entry<img src="https://www.bbiverson.com/images/buttons/next.jpg" alt="Read Next Entry" align="middle" />','no','no',1,'');
    } ?>

    Thread Starter pezastic

    (@pezastic)

    That worked wonderfully! You’re a godsend.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Coder help needed’ is closed to new replies.