Forums

[resolved] new page template with multiple loops, now blog index uses it, no idea why (5 posts)

  1. Rab
    Member
    Posted 2 years ago #

    Hi folks,

    I'm currently working on this: http://is.gd/7buWW

    I've set it up so the reading options dictate that the home page is a static page called 'Home', using a new template called 'CG Homepage' which contains 2 loops and a call to Featured Content Gallery.

    The theme was originally Kubrick which I've so far altered 'Header', 'Footer' and 'Page'. The sidebar call is currently commented out until I recode it. I'm not using the stylesheet which came with Kubrick and I'm coding my own.

    Now here's the weird thing. I haven't touched the 'Main Index' template at all yet and for some reason it's using the 'CG Homepage' template. I'm guessing it has something to do with how that template is coded.

    You can see the blog page here: http://is.gd/7bwIl

    Could someone have a look at this and let me know if they can spot anything odd or missing and point me in the right direction? That'd be awesome.

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
    Template Name: CG Homepage
     */
    
    get_header(); ?>
    
    					<div id="content">
    						<div class="featured_news"><?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?></div>
    						<div class="news_items">
    							<div class="latest_news">
    								<h2>Latest News</h2>
    								<?php
    
    									global $more;
    									$latest_news = get_posts('numberposts=1');
    									foreach($latest_news as $post) :
    										setup_postdata($post);
    										$more = 0;
    
    								?>
    									<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    										<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    											<small><?php the_time('F jS, Y') ?><!-- | Posted in <?php the_category(', ') ?> --><?php edit_post_link('Edit this entry', ' | ', ''); ?></small>
    											<div class="entry"><?php the_content("Read the rest of this entry"); ?></div>
    									</div>
    								<?php endforeach; ?>
    							</div>
    							<div class="recent_news">
    								<h2>Recent News</h2>
    									<ul>
    										<?php
    
    											$recent_news = get_posts('numberposts=5&offset=1');
    											foreach($recent_news as $post) :
    												setup_postdata($post);
    
    										?>
    										<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
    										<?php endforeach; ?>
    									</ul>
    							</div>
    						</div><br class="clear" />
    					</div>
    					<?php /* get_sidebar(); */ ?>
    					<div id="sidebar">
    						<div class="widget">
    
    							<br /><br /><br /><br /><br /><br /><br /><br />
    							<br /><br /><br /><br /><br /><br /><br /><br />
    							<br /><br /><br /><br /><br /><br /><br /><br />
    							<br /><br /><br /><br /><br /><br /><br /><br />
    							<br /><br /><br /><br /><br /><br /><br /><br />
    							<br /><br /><br /><br /><br /><br /><br /><br />
    							<br /><br /><br /><br /><br /><br /><br /><br />
    
    						</div>
    					</div><br class="clear" />
    
    <?php get_footer(); ?>

    Cheers,
    Robert

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    What's the filename of your 'CG Homepage' template?

    And next time you want to post a complete template file, you might want to use the WordPress pastebin and post the pastebin url here. It makes life easier for everyone.

  3. Rab
    Member
    Posted 2 years ago #

    It's called home.php, which now that you mention it has alarm bells ringing in my head! Some dark and distant memory tells me calling it that would replace the main index, am I right?

    Sorry about the large code section, I'll use the pastebin in future for large sections of code.

    Cheers,
    Robert

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    that would replace the main index, am I right?

    I think so. Rename the file to something like home-template.php and see if that fixes the problem.

  5. Rab
    Member
    Posted 2 years ago #

    That did the trick. Thanks esmi :)

    Cheers,
    Robert

Topic Closed

This topic has been closed to new replies.

About this Topic