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 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题