Nothing is displayed on the page. Using PHP 7.0 WordPress, Text area of a page. What am I missing? My code:

<!DOCTYPE html5>
if (1<2)  
echo "Add multiple lines of text here and watch the scrollbars grow."
  • How is this code (plain HTML + PHP) connected to WP? – kero Dec 4 '17 at 15:53
  • This code is in the text area of a wp page: <!DOCTYPE html5> <html> <body> <?php if (1<2) { echo "Add multiple lines of text here and watch the scrollbars grow." } ?> </body> </html> – Dovberman Dec 4 '17 at 15:55
  • 5
    You can't write PHP in the post/page editor. PHP goes in templates. You also shouldn't have html & body tags in the editor. You appear to be misunderstanding how to use WordPress completely. – Jacob Peattie Dec 4 '17 at 15:56
  • I go this from php.net/manual/en/tutorial.firstpage.php Example #1 Our first PHP script: hello.php <html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html> – Dovberman Dec 4 '17 at 16:01
  • 1
    Possible duplicate of How to use the php if statement – DᴀʀᴛʜVᴀᴅᴇʀ Dec 4 '17 at 16:41

I assume you are trying to create a new template file linked to a WordPress page.

Additionnal documentation : https://codex.wordpress.org/Theme_Development#Basic_Templates

To make so, you would need to do something like this :

Template Name: My first template file



    <!-- Main body -->

    if (1<2) {
        echo "Add multiple lines of text here and watch the scrollbars grow."

    <!-- End Main body -->


And in you WordPress dashboard, you only have to select your template file in the Page Attributes section.

EDIT : More information about creating a new Template File.

You can save your new file as my_first_template_file.php and you will need to upload it in your theme folder.

Normally, in your FTP it will looks like public_html/wp-content/themes/my_theme_name/.

When you will have placed the file. Just refresh your page in the WordPress Dashboard. You should see the template part.

enter image description here

  • thanks, this is a new approach for me. Please wait. I will try it. – Dovberman Dec 4 '17 at 16:07
  • 1
    If you need additionnal help, we can start a dicussion chat to avoid fulling the comments section. – Patrice Poliquin Dec 4 '17 at 16:10
  • There is no parent for this page. How do we start a chat session? – Dovberman Dec 4 '17 at 16:11
  • I just edited my post to give you more information about uploading a template file to your WordPress theme. – Patrice Poliquin Dec 4 '17 at 16:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.