TrueClicker
TrueClicker

Reputation: 35

How to create a custom PHP hello world page in wordpress?

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?

Upvotes: 2

Views: 7067

Answers (1)

doublesharp
doublesharp

Reputation: 27687

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';

?>

Upvotes: 4

Related Questions