PHP If/Else issue destroys my CSS?
-
I’m trying to implement a remaindered link feature on my personal site using Matt’s Asides hack. The live version of the site right now isn’t using the hack, so please refer to the code at the end of this post.
I have the actual functionality working when I upload the index.php file with the hack in it, but the if/else statement is messing with my layout. Essentially from what I can tell, when you get past the “if” statement, the “else” is ignoring the CSS. (i.e. the header, “if” statement post, and footer are all behaiving correctly, but the “else” statement posts (the majority of my blog) is just unstylized text sitting in between the header and footer).
Any help or thoughts would be greatly appreciated. I’m new to PHP and WP.
Here’s the index.php file:
<?php get_header(); ?>
<?php //if (have_posts()) : while (have_posts()) : the_post();// ?>
<div class="narrowcolumn">
<div id="content">
<div class="post"><?php if ($posts) {
function stupid_hack($str) {
return preg_replace('|<br/>s* |', '', $str);
} // end functionob_start('stupid_hack');
foreach($posts as $post) {
start_wp(); ?><?php if ( in_category(21) && !$single) { ?>
<div id="link">
<span class=text><?php echo wptexturize($post->post_excerpt); ?></span>
<span class="perm"><a href="<?php the_permalink(); ?>" title="Permalink: <?php echo wptexturize(strip_tags(stripslashes($post->post_title), '')); ?>" rel="bookmark">*</a></span><br/>
<span class=text><?php echo wptexturize($post->post_content); ?></span> <span class=sub><?php edit_post_link('Edit'); ?></span>
</div><!-- closes "link" --><?php
}
else
{ ?><div class="datecolumn">
<div id="date">
<?php $d = strtolower(get_the_time('D')); echo ("<img src='http://www.joshuablankenship.com/wordpress/wp-content/themes/deckard/images/w_{$d}.gif'>"); ?>
<?php $m = strtolower(get_the_time('M')); echo ("<img src='http://www.joshuablankenship.com/wordpress/wp-content/themes/deckard/images/m_{$m}.gif'>"); ?>
<?php $j = strtolower(get_the_time('j')); echo ("<img src='http://www.joshuablankenship.com/wordpress/wp-content/themes/deckard/images/d_{$j}.gif'>"); ?>
</div><!-- closes "date" -->
</div><!-- closes "datecolumn" --><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="entry"><?php the_content('Read the rest of this entry »'); ?>
</div><!-- closes "entry" --><p class="postmetadata">Posted at <?php the_time('g:i A') ?> in <?php the_category(', ') ?> |
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link">Permalink</a> |
<?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
</div><!-- closes "postmetadata" --><?php comments_template(); // Get wp-comments.php template ?>
</div><!-- closes "post" --><?php } // end else
} // end foreach loop --> posts
} // end $postelse {
echo '<p>Sorry no posts found.</p>'; } ?><?php posts_nav_link(' — ', __('« Previous Page'), __('Next Page »')); ?>
</div><!-- closes "content" -->
</div><!-- closes "narrowcolumn" -->
<?php get_footer(); ?>
- The topic ‘PHP If/Else issue destroys my CSS?’ is closed to new replies.