0

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

  • Yes, it's possible. Read the relevant documentation: http://make.wordpress.org/docs/theme-developer-handbook/part-one-theme-basics/template-hierarchy/ – brasofilo Sep 17 '14 at 17:10
  • 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 – Сергей Иванов Sep 17 '14 at 17:20
  • Read more carefuly, Page Templates: http://make.wordpress.org/docs/theme-developer-handbook/part-one-theme-basics/template-hierarchy/#page – brasofilo Sep 17 '14 at 17:22
  • 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 – Сергей Иванов Sep 17 '14 at 17:28
  • See first snapshot: http://codex.wordpress.org/Page_Templates – brasofilo Sep 17 '14 at 17:31
  • I hope I'm not completely lost :) we are talking about different things. You bringing up example about creating page (like a post) in wordpress and assigning attributes to it but I'm talking about avoiding it – Сергей Иванов Sep 17 '14 at 17:37
  • You may be looking for this too: http://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme – brasofilo Sep 17 '14 at 17:39
  • i think what you are looking for is add_rewrite_rule(), you can point to a php file. one way of doing this- http://stackoverflow.com/questions/25238480/add-custom-page-without-page/25239381#25239381 – David Sep 17 '14 at 23:53
  • thanks m8! yes this is what I was looking for. I also found one more solution – Сергей Иванов Sep 18 '14 at 06:36
  • You should check this: http://stackoverflow.com/questions/2810124/how-to-add-a-php-page-to-wordpress – ig343 Dec 24 '15 at 17:14

2 Answers2

0

here is the solution to what I was looking for

http://kovshenin.com/2014/static-templates/

0

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

Vasim Shaikh
  • 4,485
  • 2
  • 23
  • 52