<?php get_header(); ?>
<?php
$landingPage = array();
$landingPage[0]->name = 'allnewposts';
$landingPage[0]->posts = 8;
?>
<div id="column1" style="width: 550px;">
<div class="posts">
<div class="post_top" style="background-image: url('<?php bloginfo('template_url'); ?>/images/block/<?php randomBackground("top"); ?>'); height:51px;">
</div>
<?php
for ($i = 0; $i < count($landingPage); $i++) {
$cat = $landingPage[$i]->name;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('category_name=' . $landingPage[$i]->name . '&showposts=' . $landingPage[$i]->posts . '&paged=$paged');
if (have_posts()) : ?>
<?php if ($i != 0) { ?>
<div class="divider" style="margin-bottom:20px;"></div>
<?php } ?>
<!-- CATEGORY HEADER START -->
<?php
// Convert the $cat variable to uppercase
$page_heading_cat = strtoupper($cat);
// Send a query to the database looking for [HEADING_category]
$sql = "SELECT post_content FROM wp_posts WHERE post_title = '[HEADING_$page_heading_cat]' LIMIT 1";
$result = @mysql_query($sql);
// Get the page content
$post_content = mysql_fetch_row($result);
$post_content = $post_content[0];
if ($post_content) {
// Get the first image source
$sub_start = @strpos($post_content, 'src="') + 5;
$sub_end = @strpos($post_content, '"', $sub_start);
// Use custom heading
$heading_image = substr($post_content, $sub_start, $sub_end - strlen($post_content));
}
else {
// Use default heading
$heading_image = get_bloginfo('template_url') . "/images/block-headings/heading_$cat.png";
}
?>
<div class="post" style="margin-top:-20px; margin-bottom:-10px;">
<img src="<?php echo $heading_image; ?>" alt="<?php echo $cat; ?>" />
</div>
<!-- CATEGORY HEADER END -->
<?php $pointer = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" style="padding-top:0px; padding-bottom:30px;">
<h2 id="post-<?php the_ID(); ?>" class="<?php echo $cat; ?>">" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></h2>
<?php the_content('More...') ?>
<div class="metadata">
<div class="<?php echo $cat; ?>">
<div class="alignright" style="text-align: right;">
<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
</div>
<img src="<?php bloginfo('template_url'); ?>/images/comment.png" alt="" />
<?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?>
<?php if(function_exists('wp_email')) { email_link(); } ?>
<?php edit_post_link('Edit this post', '
', ''); ?>
</div>
</div>
</div>
<?php $pointer++; if ($pointer < $landingPage[$i]->posts) { ?>
<div class="divider"></div>
<?php } ?>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Stuff') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Stuff »') ?></div>
</div>
<?php else : ?>
<div class="post">
<h2 class="center">No posts found</h2>
<?php include (TEMPLATEPATH . '/searchform.php'); ?>
</div>
<?php endif; ?>
<?php } ?>
<div id="bottom" style="background-image: url('<?php bloginfo('template_url'); ?>/images/block/<?php randomBackground("bottom"); ?>');"></div>
</div>
</div>
<div id="column2" style="width: 270px;">
<?php $cat = "girls"; include("sidebar.php"); ?>
</div>
<?php get_footer(); ?>