I have developed some calculators (in php) for my website and I need WordPress integration.
The calculators have a form and, after submission, the result is shown. The result depends on a query in the database. Is it possible to create “static pages” (at least static URLs) that provide to the user dynamic content?
Just to clearfy, I want something like:
website/blog website/forum website/calculators website/calculators/one website/calculators/two
I heard about Pages, but I cannot include php code on it. Worth point out that the calculators aren’t static, the result will change everyday.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You do want static pages. The easiest way to do this, and a very good way even if perhaps not the only way, is:
-
Create one or more custom template files for your static pages. This is where your PHP comes in.
/* Template Name: Calculator */ get_header(); // your calculator code // Whatever PHP you have should work // This is very minimal. You may want something more complicated. get_footer();
- Save the file as some name not on the reserved list
- Create your static pages from wp_admin->Pages. Why creating the pages, save them with appropriate “Template”– that is, one of the ones you’ve created. (Look in the right sidebar under “Page Attributes”.)
This way, you can keep the calculator pages consistent with the other pages on the site.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0