If you want to read the previous tutorial, Please click the following link. http://1wmedia.blogspot.in/2016/04/creating-pagephp-default-template-and.html
Ok. Now we will move to topic.
In this tutorial we will learn how to create custom template and sidebar template (We will see how to create widget, sidebars in the next tutorial.)
If you want to create a custom template just do the following steps.
1. Create a new php file (In our case, save as the file page.php into page-sidebar.php) and add the following code.
?php
/*
Template Name: Your Template Name here
*/
?>
2. There is no space between : and Template Name in the above code
3. In our tutorial, We will use our template name which is "Sidebar Template" instead of "Your Template Name here"
4. Now save it. That's all for creating new or custom template in WordPress.
5. Now add the following code or replace page-sidebar.php code with the following:
<?php get_header(); ?>
<!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="first-slide" src="<?php bloginfo('template_directory'); ?>/images/avoid when blogging.jpg" alt="First slide">
</div>
</div>
</div><!-- /.carousel -->
<!-- Marketing messaging and featurettes
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->
<div class="container marketing">
<!-- Three columns of text below the carousel -->
<div class="row">
<div class="col-md-8" >
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="container">
<h1> <?php the_title(); ?> </h1>
</div>
<p><?php the_content(); ?></p>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
<div class="col-md-4" >
<p>This is our sidebar space</p>
</div>
</div><!-- /.row -->
<hr class="featurette-divider">
<?php get_footer(); ?>
6. Now save the file in theme folder and move to your Dashboard -> Pages -> Edit a page -> Page attributes -> Template -> here you will see a new template with our template name. Sidebar Template is our template here.
7. That's all
Video tutorial:
Ok. Now we will move to topic.
In this tutorial we will learn how to create custom template and sidebar template (We will see how to create widget, sidebars in the next tutorial.)
If you want to create a custom template just do the following steps.
1. Create a new php file (In our case, save as the file page.php into page-sidebar.php) and add the following code.
?php
/*
Template Name: Your Template Name here
*/
?>
2. There is no space between : and Template Name in the above code
3. In our tutorial, We will use our template name which is "Sidebar Template" instead of "Your Template Name here"
4. Now save it. That's all for creating new or custom template in WordPress.
5. Now add the following code or replace page-sidebar.php code with the following:
<?php get_header(); ?>
<!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="first-slide" src="<?php bloginfo('template_directory'); ?>/images/avoid when blogging.jpg" alt="First slide">
</div>
</div>
</div><!-- /.carousel -->
<!-- Marketing messaging and featurettes
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->
<div class="container marketing">
<!-- Three columns of text below the carousel -->
<div class="row">
<div class="col-md-8" >
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="container">
<h1> <?php the_title(); ?> </h1>
</div>
<p><?php the_content(); ?></p>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
<div class="col-md-4" >
<p>This is our sidebar space</p>
</div>
</div><!-- /.row -->
<hr class="featurette-divider">
<?php get_footer(); ?>
6. Now save the file in theme folder and move to your Dashboard -> Pages -> Edit a page -> Page attributes -> Template -> here you will see a new template with our template name. Sidebar Template is our template here.
7. That's all
Video tutorial:
No comments:
Post a Comment