Search code examples
wordpresscustom-wordpress-pages

Add a large complex custom page to Wordpress?


I have a quite a large html page with it's own css and Javascript that I want to add to my Wordpress site, I created a custom page, which works, but when I paste the code from my own page into it I get the following error:

 Parse error: syntax error, unexpected '<', expecting end of file in 
 C:\wamp64\www\wordpress\wp-content\themes\shapely\Custompage2.php on line 6

My custom page looks like this, I wont post the whole thing as it's massive:

<?php /* Template Name: CutomPageT2 */ 
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> (this is line 6, including spaces)
<meta name="viewport" content="width=device-width,initial-scale=1">
----javascripts, css, rest of page etc
----
----
</table>
</div
</body>
</html>
?>

Solution

  • Try this solution for the top of your page :

    <?php 
    /* 
        Template Name: CustomPageT2 
    */ 
    ?>
    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    

    Never include your HTML in your PHP. Never ! ^^

    EDIT :

    Change the name of the page to page-custompaget2.php.