user2725936
user2725936

Reputation: 505

How to call a page template in another page in php- Wordpress?

OK. I have page template called "bannerpage.php". How do I call this page so that the contents of this page are displayed on the homepage.php

I know that most common templates that have associated template tags (i.e., , , , etc.), can be called but I don't know how to call a "non-standard" template like bannerpage.php in Wordpress.

Any help would be much appreciated.

Upvotes: 1

Views: 9901

Answers (3)

William Buttlicker
William Buttlicker

Reputation: 6000

The best way is to choose your page template from the backend page.enter image description here

Or..You can also include it in home page by :

include('bannerpage.php');

Upvotes: 3

iEmanuele
iEmanuele

Reputation: 1566

Use get_template_part();

Load a template part into a template (other than header, sidebar, footer). Makes it easy for a theme to reuse sections of code and an easy way for child themes to replace sections of their parent theme.

From WordPress Codex

Upvotes: 0

Ronny K
Ronny K

Reputation: 3751

in the homepage.php file add include('bannerpage.php');

Upvotes: 3

Related Questions