0

I want to Build a custom Page Template. But as far as I know we should not at all touch Core PHP files.

let say our Custom Page template is custom.php, then where will this custom.php sit I mean in which folder in wordpress or it will go some where in the inner directories of theme?

Because Finally while creating a new page it should be available as drop down in WordPress admin.

0

This is covered in the Codex, under How to create a page template.

In your theme you create a file called my-bacon-template.php and in that file you add the following to the top of the file, before any other code

<?php
/*
Template Name: My Bacon Page
*/

After that you can put any content you want and it will display on any page that you have selected to have this template.

0

Amusing you know how to crate a page template. If not, refer to codex.

Put the files anywhere in your plugin and this code should help you include them in Page template chooser.

function include_template() {
    return locate_template( array (
                'templateone.php',
                'templatetwo.php',
                'templatethree.php',
            )
        );
}
add_action('template_include', 'include_template');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.