2011-04-12 68 views
0

我正在使用php if语句在用户未登录时显示图形,但问题在于。)我不擅长php和b。)if声明踢我的右边栏到我的#contentleft股利,当他们应该是兄弟姐妹。你能告诉我我在这里做错了吗?php,div嵌套问题

的代码:

<div id="contentleft"> 

    <?php 
    if (is_user_logged_in()) { 
      echo 'Welcome, registered user!'; 

    } else { 
      echo '<div id="intro"><p><a href="http://www.wespeakfashion.com/submissions">Sign up</a> and start posting!</p></div>'; 

    }; 
    ?> 

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
    <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> 

    <p class="date"><b>Posted on</b> | <?php the_time('F j, Y'); ?> | <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p> 
     <?php global $wpdb; 
       $query = "SELECT `ID`, `guid` FROM `$wpdb->posts` WHERE `post_type` = 'attachment' AND `post_parent` = '{$post->ID}'"; 
       $adimages = $wpdb->get_results($wpdb->prepare($query), OBJECT); 
     // To display the first image.. ?> 

     <img style="float: center; height: 500px;" src="<?php if(is_public_submission()){echo $adimages[0]->guid;} ?>" /> 

    <?php the_content(__('Read more'));?><div style="clear:both;"></div> 

    <div class="bt-links"><strong>Category:</strong> <?php the_category(', ') ?><br /><?php the_tags('<strong>Tags:</strong> ',' > '); ?></div> 

    <!-- 
    <?php trackback_rdf(); ?> 
    --> 

    <h3>Comments</h3> 
    <?php comments_template(); // Get wp-comments.php template ?> 

    <?php endwhile; else: ?> 

    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?> 

    </div> 

<?php include(TEMPLATEPATH."/r_sidebar.php");?> 

</div> 

感谢一束。

回答

1

我很困惑。您在#contentLeft div中包含r_sidebar.php。难道你不能把它移出div吗?

相反的:

<?php include(TEMPLATEPATH."/r_sidebar.php");?> 
</div> 

务必:

</div> 
<?php include(TEMPLATEPATH."/r_sidebar.php");?> 

很抱歉,如果这不是问题的答案(这似乎太容易了),但是如果你能对你的问题详细说明,我相信我可以多帮忙!

+0

是的,这发生在我身上,我可能只是用这个解决方案。奇怪的是,对我来说,'#r_sidebar'是我登录时'#contentleft'的兄弟,但是当我退出后,它就成了它的孩子。由于我自己在写PHP,我认为这与我的if语句有关。谢谢,@andrewpthrop。 – blackessej 2011-04-12 17:13:46