I have an order.php that is in fact a custom page template. This template loads the first step of my order form via:

<?php include('order/order-step-one.php'); ?>

Now in this order-step-one.php my Next-button (post method) has to send the user to /order/order-step-two.php

Currently this does not work. I need to find a way to include order-step-two in the original order.php via the submit button in order-step-one. How do I achieve this?


In your order.php you will need something like this:

$step = (isset($_POST['step'])) ? $_POST['step'] : 'one';

switch ($step) {
    case 'one':
      // do step one
    case 'two' :
      // do step two
    case 'three' :
      // do step three

Your form, of course, has to send the appropriate arguments. I used POST, which seems most appropriate for this kind of thing, but the same would be true for GET.

This makes everything process on your one page which WordPress knows about and that will greatly simplify things.

| improve this answer | |
  • I'm having trouble implementing this. Why do I get Unexpected '=' on line 30? thus after step = (isset... – Forza Jun 27 '13 at 18:24
  • Because I have a typo. Give me 2 minutes. – s_ha_dum Jun 27 '13 at 18:25
  • You are missing ; on the line endings, for one. Do it just like I did. If you want to change the value substitute order-step-one for one in my code. But if you are having trouble with PHP syntax you best going to the PHP Docs. – s_ha_dum Jun 27 '13 at 19:01
  • Solved it. Thx for your help s_ha_dum :) – Forza Jun 27 '13 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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