custom-page template ignored and single.php used.
-
I wrote a shortcode that presents the user with a form. I have the form post back to the same page. So
https://somesite/?page_id=36 Takes the user to the page with the shortcode, and the user sees a form.
user fills out form and selects the submit button
form is posted back to https://somesite/?page_id=36.
shortcode code gets exercised again, this time processing the form.
I have an edit for some fields in the shortcode code, and if it fails, an error is added to the form. This all actually works well.
If I pass validation, instead of re-presenting the user with the filled out form page as it should, I get a “query not able to find posts matching…”
What I discovered is that instead of going back to https://somesite/?page_id=36 and using the assigned custom template, single.php is being used. But this is a page, not a post.
I am having trouble tracking down where the error is occurring in template selection, or why. I have gone as far as to comment out most or all the code that get exercised if the form passes validation, but the error still occurs.
Suggestions?
$myId = '191'; $utility = new PersonUtility(); if (!isset($_POST['submitPersonForm'])) { $id = isset($_GET['id']) ? trim($_GET['id']) : ''; if(strlen($id) >= 2) { $fileName = "wp-content/plugins/rootsPersona/" . get_option("rootsDataDir") . '/' . $id . '.xml'; if(file_exists($fileName)) { $xml_doc = new DomDocument; $xml_doc->load($fileName); $p = $utility->paramsFromXML($xml_doc); } } $p['action'] = get_option('siteurl') . '/?page_id=' . $myId; return $utility->showForm($p); } else { $p = $utility->paramsFromHTML($_POST); if(strlen($p['id']) < 2) $msg = $msg . "<br />Invalid Id."; if(strlen($p['name']) < 1) $msg = $msg . "<br />Name required."; if(!isset($msg)) { $fileName = "wp-content/plugins/rootsPersona/" . get_option("rootsDataDir") . '/' . $p['id'] . '.xml'; $xml_doc = new DomDocument; if(file_exists($fileName)) { $xml_doc->load($fileName); } else { $xml_doc->load("wp-content/plugins/rootsPersona/" . get_option("rootsDataDir") . '/templatePerson.xml'); } $xml_doc = $utility->paramsToXML($xml_doc, $p); $xml_doc->save($fileName); $p = $utility->paramsFromXML($xml_doc); $msg = "<br />Saved."; } $p['action'] = get_option('siteurl') . '/?page_id=' . $myId; return $utility->showForm($p, "<div class='truncate'>" . $msg . "</div>"); //return $msg; }
- The topic ‘custom-page template ignored and single.php used.’ is closed to new replies.