0
votes

I'm trying my make my first theme for wordpress.

Is there any possibility to create custom php page to display custom content? Pretty much adding to WordPress another copy of the likes of single.php, post.php or 404.php.

All I want just a page to display the custom content on it. Every tutorial I found so far uses just creating new page within WordPress.

I want to avoid it and for custom page to be enabled straight after theme activation. The Idea is to have something like my_custom_page.php and to be able link to it after.

Is there any way of doing it? Thanks

2
Yes, it's possible. Read the relevant documentation: make.wordpress.org/docs/theme-developer-handbook/… - brasofilo
hi!thanks for reply, but I had a look at it before? but with no help. It does not say anything about creating such a pages - Сергей Иванов
Read more carefuly, Page Templates: make.wordpress.org/docs/theme-developer-handbook/… - brasofilo
from what I understand custom page template could be applied only to existing page with page ID. but I want to create "stand alone" page. I hope my explanation makes sense - Сергей Иванов

2 Answers

0
votes

To achieve custom page functionality you can use page template concept of wordpress. Creating a page template is extremely easy. Create any new file in your theme and start the file with a comment block like so:

<?php
/*
Template Name: My Awesome Custom Page
*/


<h1>Hello There</h1>

You need paste php code inside this template file. When you submit for then redirection action will be page with custom template page.

Referance :

https://premium.wpmudev.org/blog/creating-custom-page-templates-in-wordpress/

Video : https://youtu.be/1ZdHI8HuboA