• I have worked with wordpress before with never a problem. The codex is wonderful at solving most of my problems. But alas, I have come across something that leaves me completely baffled.

    I read and re-read and re-read the information on how to create a custom template. So I did that but then when I set my front page to use the template, one of two things happen.

    I either get strings of odd code in the header and /par/par /tab/tab showing up in the middle of the content OR it tells me that there is an error in the template on line 2.

    Here is what I’m trying to do. The front page has content then a slider shows 5 featured blog posts. The posts are on another page (blog).

    However, I don’t want the slider showing the featured posts on every single page, which is what happens when I change the page.php template.

    So I tried to create a template named “Slider” based on the instructions given here: https://codex.www.ads-software.com/Pages#Creating_Your_Own_Page_Templates for the front page, leaving page.php with it’s original code in the custom theme to handle the other pages. I’ve even tried making a “noslider” template for the other pages instead, but I get the same result – the error telling me there is something wrong with line 2.

    If I go with creating a file named front-page.php then the funky code shows up all over the place.

    Is there something I’m missing? This is really driving me nuts, because I know it works!

    Here is the code for page.php (with the slider)

    <?php get_header(); ?>
    
    <div id="content">
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="single" id="post-<?php the_ID(); ?>">
    <div class="title">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    </div>
    
    <div class="cover">
    <div class="entry">
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    		<div class="clear"></div>
     <?php wp_link_pages(array('before' => '<p><strong>Pages: </strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    </div>
    
    </div>
    
    </div>
    
    <?php endwhile; endif; ?>
    
    		<div class="slidercontent">
    
    		     <?php include (TEMPLATEPATH . '/slide.php'); ?>
    
    		     <?php include (TEMPLATEPATH . '/ad1.php'); ?>
    
    		</div>
    
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    But when I try to make a template for the other pages using this code:

    <?php
    /*
    Template Name: NoSlider
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content">
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="single" id="post-<?php the_ID(); ?>">
    <div class="title">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    </div>
    
    <div class="cover">
    <div class="entry">
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    		<div class="clear"></div>
     <?php wp_link_pages(array('before' => '<p><strong>Pages: </strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    </div>
    
    </div>
    
    </div>
    
    <?php endwhile; endif; ?>
    
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    everything is messed up. Is it because I’m copying the exact same loop code over again?

    Thanks in advance for any help with this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Anastasia Pergakis

    (@harleydpalmer)

    Oh, here is the link to the website I’m trying to build, so you can see the front page in full. I don’t have any real content up yet, since I’m trying to build this for a friend – and can’t get the templates to work as I said.

    https://scottfalzone.com

    You’ll notice the slider is on every page, but like I said, I only want it on the front page.

    Can you post the error messages that you’re getting?

    Thread Starter Anastasia Pergakis

    (@harleydpalmer)

    I don’t know what happened. But when I tried to recreate the issue to get the exact error message – suddenly it worked! So, now everything is the way it’s supposed to be. I don’t understand or know why it wouldn’t work before (for two days!!) but now it is.

    So, I’m closing this, since the steps in the wordpress codex DO actually work. Maybe my server was just having issues?

    Either way, I’m just glad it works now.

    Thanks tnoguchi for responding to help me so quickly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Page Templates Causes Errors’ is closed to new replies.