james4551 Posted June 22, 2009 Share Posted June 22, 2009 Hi there, I have basically been picking apart a wordpress theme but am amatuer at PHP, I'm sure though not all this code regarding the landingpage and pointer is necessary as I just want it to display as a normal blog such as the wordpress default, all the landing page code is doing is making me have to tick an extra category in the dashboard. Could anyone help me out identify what is redundant and suggest a rewrite of it please? <?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;"> <img src="<?php bloginfo('template_url'); ?>/images/block/heading_home.png" alt="<?php echo $cat; ?>" /> </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); $wp_query->is_archive = true; $wp_query->is_home = false; 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"; } ?> <!-- CATEGORY HEADER END --> <?php $pointer = 0; ?> <?php while (have_posts()) : the_post(); ?> <div class="post" style="padding-top:5px; padding-bottom:30px;"> <h2 id="post-<?php the_ID(); ?>" class="<?php echo $cat; ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></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', '<br />', ''); ?> </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 = "allnewposts"; include("sidebar.php"); ?> </div> <?php get_footer(); ?> Link to comment https://forums.phpfreaks.com/topic/163223-need-help-identifying-redundant-code/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.