-1

I am creating my own WordPress theme in which i create lib folder where i put my page template inside it (ex page-feedback.php,page-contact.php) by doing this my whole theme is messed the problem that the template that is present inside the lib folder is not getting load. So how could i able to import that template from lib folder to my theme.

1 Answers1

1

The template files with the given default template naming such as (page-about.php, archive.php, taxonomy.php, etc.) must always be placed on the theme home directory so that wordpress engine can fetch them.

But if you want to organize your page templates (only page templates) then there is a way. Add the following lines at the beginning of the template file you want to create and name the files the way you want (such as about_template.php, contact_template.php, etc). Place these files on any folder you want (inside the theme home directory).

<?php
    /**
     * Template Name: Template Name //change this name to the name you want
     *
     * @package WordPress
     * @subpackage Twenty_Fourteen
     * @since Twenty Fourteen 1.0
     */

Once you have done so, go the Add New Pages on your dashboard and attach the template to the page.

Wordpress Developer Resources::

Organizing Template Files

Template Hierarchy

Page Templates

archvayu
  • 438
  • 4
  • 13
  • Actually i go through the documentation and read the page structure .there i found (is_page()) the function is used to get a certain page –  Feb 19 '17 at 17:51
  • is_page() is not used to get page but is used to check whether you are in page or not, it returns true if you are viewing the page. there are functions similar to is_page such as is_archive() to check whether the view is archive page. Check out the last link in above post, it describes the page templates which will help you in a manner. – archvayu Feb 19 '17 at 18:04
  • Glad it worked for you. Please accept the answer as solution if it solved your question. – archvayu Feb 20 '17 at 01:35