php, div nesting issue
I'm using a php if statement to display a graphic when users aren't logged in, but the problem is that a.) I'm not great with php yet and b.) the if statement kicks my right sidebar into my #contentleft
div, when they should be siblings. Can you tell me what I'm doing wrong here?
the code:
<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(__('R开发者_StackOverflow社区ead 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>
Thanks a bunch.
I am confused. You are including the r_sidebar.php inside of your #contentLeft div. Would it not behove you to move it out of the div?
Instead of:
<?php include(TEMPLATEPATH."/r_sidebar.php");?>
</div>
Do:
</div>
<?php include(TEMPLATEPATH."/r_sidebar.php");?>
Sorry if that is not the answer (it seems too easy) but if you could elaborate on your problem, I am sure I could be more help!
精彩评论