2011-04-12 9 views
0

사용자가 로그인하지 않았을 때 그래픽을 표시하기 위해 PHP if 문을 사용하고 있지만 그 문제는 다음과 같습니다.) PHP는 아직 좋지 않지만 b) if 내 오른쪽 사이드 바를 내 #contentleft div에 넣고 형제가되어야합니다. 내가 여기서 뭘 잘못하고 있는지 말해 줄 수 있니?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

혼란 스럽습니다. #content 왼쪽 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 문과 관련이 있다고 생각했습니다. 고마워, 앤드류 프롭. – blackessej