Home » Php » WordPress functions not working custom page

WordPress functions not working custom page

Posted by: admin May 27, 2018 Leave a comment

Questions:

I’ve created a page called “page-myslug”.

<?php
/*
Template Name: myslug
*/

I see that in the back-office, but when I go to the page through url (so www.mywp.com/wp-content/themes/site/page-myslug.php?value=4243 => value=4243 because my page is for create PDF, it’s not WordPress in the proper way). I have an error message saying that my functions aren’t defined (I used them to create url to display PDF thanks to TCPDF). It’s working if I add :

require($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');

But it’s clearly not recommanded, so what can I do to fix that?

Answers: