How To Create Custom Page Template Without Plugin in Wordpress

What is WordPress?

WordPress is a CMS Framework, Now you are thinking what is CMS? so CMS is a Content Management System, which allows you to manage your application or website without any coding knowledge.

Why we use Custom Templates in WordPress?

Let me tell you, by default WordPress allows you to create posts, pages, categories, and also they provide good basic page Design but the default design is not pretty good that's why we need to Create Custom Page Templates.

Important Points :

1. First we need to learn how WordPress Works Check me

2. WordPress Directory Structure?  Check me

How we can Create Custom Page Template Without Plugin in WordPress

First go to your root theme folder and Create new file give name and extension must be .php
because WordPress uses PHP Language. After creating a file open file Write this code.

File Name => Template-custom-template.php


<?php

/**
 * Template Name: Your_Template_Name
 */

// That Function For Calling Header Section

get_header();
?>

<?php if ( have_posts() ) : ?>
<?php
/* Start the Loop */
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', 'custom-template' );
endwhile;
endif;
?>

<?php
get_sidebar();
get_footer();



Now make another file inside the Template-parts folder.

File Name => content-custom-template.php  ( Inside that file write your custom design )

After creating the file open Inside that file writes your custom design.

After Setup a file or code stuff go to WordPress Dashboard and click on all Pages and create a new page find the Page Attributes and Select Your Template Name and publish your page and open the page. 

Notice :  Ask me if you want more articles for WordPress Development below in the comment section and please share this post with your friends.

Comments