banner



How To Save A Wordpress Page As A Separate Template Php

Cutsom WordPress templates

WordPress themes are merely keen. They make WordPress web design so like shooting fish in a barrel.

But, what happens when you want to get beyond your called theme?

What if you want to utilize a custom WordPress layout on a particular page?

Well, some themes won't allow you to alter their layouts.

Image result for mine meme

Simply there are some workarounds for this.

Follow me to observe out.

What is a Custom Folio Template and How to Assign I?

WordPress pages and posts layout are controlled by a template file named "page.php". Templates are files that tell WordPress how to brandish different types of content.

At present, you might not want all pages and posts to look the same. This is when yous need a custom folio template.

What WordPress page templates are you using?

Wanna find out what page template y'all're using, or how to switch between templates?

It'south easy peasy, you'll need to:

  1. Head over to your WordPress Admin Dashboard,
  2. From the menu on the left, select "Pages",
  3. Hover over the title of a page,All Pages in WordPress
  4. From the menu below the championship, select "Quick Edit",
  5. From the "Quick Edit" window, go to the "Template" dropdown.

WordPress templates

Hither yous can see all the available theme templates, and yous tin can assign a different template to your current page.

For example, there's an choice to alter your page to full width, if yous'd like. But in that location'south no option for a template that adds a second sidebar.

This is why custom WordPress templates can come in handy. Whenever you save a new template, information technology will exist available alongside the sometime ones besides.

At present, you can assign do this consignment inside the page every bit well. When you lot choose to edit a page, on the right-hand side, head over to "Page Attributes" -> Template.

Assigning a page template

How to Create a Child Theme

At present, before getting our easily muddied with creating a WordPress custom folio template, at that place's i affair to bear in mind: brand the changes on a kid theme. Yous wouldn't want to cause any irreversible changes to the parent theme.

A WordPress child theme is a sub-theme that inherits all the features and styles of the parent theme. Now, if the parent theme gets an update, your child theme won't exist affected and your changes won't be overwritten.

Now, how practise you lot create a child theme? Here are the steps:

  1. Login to your cPanel,
  2. Get to File Manager,Access File Manager inside cPanel
  3. Head over to public_html -> wp-content -> themes folder,Access Themes folder in cPanel
  4. While inside the "Themes" folder, add a new folder from "+Binder" in the upper menu. Give it a proper noun. A all-time-instance practise is to utilize the name of the theme, to which you lot append "-child". Too, employ hyphens, instead of infinite. In my case, I'grand going to use mesmerize-kid, because I'yard using the Mesmerize theme,
  5. Inside the binder, create a new file and call it  "fashion.css",Create style.css in cPanel
  6. . Right-click on the file and select the "Edit" option.
    /*  Theme Name: Your Theme Child  Theme URL: http://yourdomain.com Description: Your Theme Child  Theme Writer: Your Name Author URL: http://yourdomain.com Template: yourtheme  Version: 1.0.0  Text Domain: yourtheme-child  */

    Hither y'all can paste some of the code in the parent CSS file, or add together your own styling.

  7.  Change the theme and domain names, then hitting "Save",
  8.  Create another file in the same folder. This time name information technology "functions.php". Paste the following code:
    <?php add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' ); function enqueue_parent_styles() {    wp_enqueue_style( 'parent-way', get_template_directory_uri().'/style.css' ); } ?>
  9. Get to the WordPress Dashboard, Appearance -> Theme. Your child theme will exist there, yous just accept to activate it.

And you're done.

Next, let's make a new template, shall nosotros?

How to Create a WordPress Custom Page Template?

Y'all tin start from the existing theme lawmaking and make the necessary adjustments.

Here are the steps:

  1. Become to cPanel -> File Manager,
  2. Navigate to public_html -> wp-content -> themes folder,
  3. Open your principal theme folder,
  4. Identify the page.php file. It volition look like this:
    <?php mesmerize_get_header(); ?>      <div id='folio-content' class="folio-content">         <div class="<?php mesmerize_page_content_wrapper_class(); ?>">             <?php             while (have_posts()) : the_post();                 get_template_part('template-parts/content', 'folio');             endwhile;             ?>         </div>     </div>  <?php get_footer(); ?>
  5. Select the file and then choose "Copy",
  6. In the window that pops upwards, change the path of the file, to the one in your theme child binder,Copy page.php to new file location
  7. Rename the new file so that you tin can hands identify what it does.
  8. Add a annotate inside the file and so that you tin tell WordPress that this is a new custom template. Do this by selecting "edit" and inserting this text:
    /*  * Template Name: Your custom TEmplate's name  * description: >-  Explain what your new templates does  */

    Your new file should look similar this:

    <?php  /*  * Template Name: Custom Total Width  * description: >-   Page template without sidebar  */ mesmerize_get_header(); ?>      <div id='page-content' class="page-content">         <div course="<?php mesmerize_page_content_wrapper_class(); ?>">             <?php             while (have_posts()) : the_post();                 get_template_part('template-parts/content', 'folio');             endwhile;             ?>         </div>     </div>  <?php get_footer(); ?>

Yous can add here copies of other files besides. For example, you can customize the unmarried.php file, which volition change the look and feel of web log posts.

Adjacent, you'll need to whorl up your sleeves and write some lawmaking.

And if you desire to alter CSS styling, you can do this inside the child theme Customizer, inside Aditional CSS or within the fashion.css file.

Notwithstanding, in that location's a simpler solution…

With a site builder like Colibri, all the code "stands" behind, and doesn't block a non-technical site creator. Every addition or alter to a custom page is visually reflected in the Customizer. Thus, the site creator has more control over the design. The pretty custom page volition exist set in the blink of an eye, with no bothering for the lawmaking backside the page.

We hope this commodity has made it clear what a custom page is, and why you might demand one. Coders and non-coders can now be able to create custom pages as they wish.

Alina

Alina Belascu

Alina is a digital marketer with a passion for spider web blueprint. When she's not strategizing she's doing photography, listening to podcasts on history and psychology, and playing with her 2 dogs and cat.

How To Save A Wordpress Page As A Separate Template Php,

Source: https://colibriwp.com/blog/wordpress-custom-page-template/

Posted by: josephphisecome.blogspot.com

0 Response to "How To Save A Wordpress Page As A Separate Template Php"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel