2

I want to createa menu item link that refers to a page where I can write something like:

<?php

echo 'hello world';

?>

this is what I mean by custom page, I see the examples but there people are creating templates, I just need a simple custom page is that possible?

8
  • 1
    Just dump your php file in the docroot and request it like you would normally do: http://yourdomain.com/yourpage.php Commented Aug 16, 2014 at 18:12
  • @PeeHaa yeah this is good, but not a wordpress way to do things :), so I can use in this custom file a wordpress core functions? if yes, thats really good, anyway I will use it, cause I don't have another choice :DD, also how could I create a menu link that will refer to this custom php file? it looks like little complicated Commented Aug 16, 2014 at 18:19
  • stackoverflow.com/q/9101503/508666 Commented Aug 16, 2014 at 18:21
  • @PeeHaa This is not the proper way to create a WordPress template - there is a standard naming convention that will automatically load the required functions. Commented Aug 16, 2014 at 18:53
  • @doublesharp As per OPs requirement from his question yeah "...but there people are creating templates, I just need a simple custom page..." Commented Aug 16, 2014 at 18:54

1 Answer 1

4

There are several ways to create custom page templates in WordPress with the documentation found under Theme Development. If you are developing your own theme, you can just use the naming conventions found under the Template Files List, or if you are using a theme developed by someone else you should first create a Child Theme and then add your custom templates under it. You can also make any PHP file under your theme a Custom Page Template by adding a comment at the top of the page. WordPress will automatically detect this file and the template will become accessible via the Page Edit screen in the WordPress Admin.

The short version - add a file called page-custom-template.php to your theme directory (typically /wp-content/themes/YOUR_THEME_DIR/ and add the following comment at the top:

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

// your code goes here
echo 'hello world';

?>
Sign up to request clarification or add additional context in comments.

1 Comment

Great links for the beginner by the way. Simple to follow. I added a child theme in about 10 minutes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.