WordPress.org

Ready to get started?Download WordPress

Forums

My Life
New template (5 posts)

  1. twoems
    Member
    Posted 1 year ago #

    Hello, I?m a beginner with wordpress, I'm using My Life theme for a website i'm making, but I've encountered a problem. I'm trying to create a new template for a static page, but when I do it, and assign it to a page...nothing happens, and only the text is loaded by the browser. Someone told me it could be caused by an incompatibility of the theme with new templates. Could u help me and tell me what the problem could be ?
    thank you very much

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    create a new template for a static page

    what is the full code of that page template?
    can you post a link to a page using that template?

    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

  3. twoems
    Member
    Posted 1 year ago #

    Well, the website isn't online yet. I am using My Life theme I took from wordpress.org
    This theme has no page.php, but only index. I added to the index.php a line of code to add a slider just under the header. And I wanted to make a new page template with no slider. Here's the code of this new template, that in other word is the same of the original index.php of the theme:

    <?php
    /*
    Template Name: no slide
    */
    ?>
    
    get_header(); // Loads the header.php template. ?>
    
    	<?php do_atomic( 'before_content' ); // my-life_before_content ?>
    
    	<div id="content">
    
    		<?php do_atomic( 'open_content' ); // my-life_open_content ?>
    
    		<div class="hfeed">
    
    			<?php get_template_part( 'loop-meta' ); // Loads the loop-meta.php template. ?>
    
    			<?php if ( have_posts() ) : ?>
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php get_template_part( 'content', ( post_type_supports( get_post_type(), 'post-formats' ) ? get_post_format() : get_post_type() ) ); ?>
    
    					<?php if ( is_singular() ) { ?>
    
    						<?php do_atomic( 'after_singular' ); // my-life_after_singular ?>
    
    						<?php comments_template( '/comments.php', true ); // Loads the comments.php template. ?>
    
    					<?php } ?>
    
    				<?php endwhile; ?>
    
    			<?php else : ?>
    
    				<?php get_template_part( 'loop-error' ); // Loads the loop-error.php template. ?>
    
    			<?php endif; ?>
    
    		</div><!-- .hfeed -->
    
    		<?php do_atomic( 'close_content' ); // my-life_close_content ?>
    
    		<?php get_template_part( 'loop-nav' ); // Loads the loop-nav.php template. ?>
    
    	</div><!-- #content -->
    
    	<?php do_atomic( 'after_content' ); // my-life_after_content ?>
    
    <?php get_footer(); // Loads the footer.php template. ?>

    All i want to do is to add the slider under the header only in the homepage, and use a template without the slider for all the other pages.

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    you have closed the php tag before the get_header line;

    corrected:

    <?php
    /*
    Template Name: no slide
    */
    get_header(); // Loads the header.php template. ?>
  5. twoems
    Member
    Posted 1 year ago #

    yes thanks, now it works good :)

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.