dsx666666 2012-01-08 15:34
浏览 19
已采纳

试图在页面顶部获得条件登录框/欢迎文本? 救命?! (WORDPRESS)

Thanks in advance for any help.

I am using a highly customised version of Twenty Eleven Wordpress Theme and basically I am trying to add a section into my header.php to appear at the top of all pages. It is to be two things.

1) If you are logged in, display the text "Welcome, USER NAME" 2) If you are logged out, display the text "Login Now >" which will then link to a lightbox or hover of somesort with the login box itself.

I am proficient with HTML/ CSS and a novice but like to experiment with PHP and I thought I had it sussed but it keeps spitting out errors, with the code below I get an error. (Code below, then error follows).

<div id="login">

        <!-- Content to be shown if logged in -->
        <?php if ( is_user_logged_in() ) ?>

            <!-- Display Username / if logged in -->
            <p class="logn-text-top">Welcome, <?php echo $current_user->user_login; ?></p>

        <!-- Content to be shown if not logged in -->   
        <?php } else { ?>

            <a href="#"><p class="login-text-top">Login Now<span>></span></p></a>

        <?php } ?>

        </div>

The Error I get is:

*Parse error: syntax error, unexpected '}' in /web_local/docroot/1310/cheshirefitcamps.co.uk/htdocs/wp-content/themes/cheshirefitcamps/header.php on line 107*

I've checked the code over and searched the net but as far as I can see the code is fine.

Any help would be appreciated.

Kind Regards, Tom

  • 写回答

1条回答 默认 最新

  • dongzhan1948 2012-01-08 15:37
    关注

    You don't have an opening brace, directly after the if condition...should be as below

     <?php if ( is_user_logged_in() ) { ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解
  • ¥15 有偿请教计算电磁学的问题涉及到空间中时域UTD和FDTD算法结合的
  • ¥15 three.js添加后处理以后模型锯齿化严重