AI Summary
When you view your Survey Results or Print Survey Report in WPForms, you may notice that the questions don’t always appear in the same order as they do in the form builder.
This happens because WPForms uses each field’s internal field ID to determine the order of questions in the report. If you added, removed, or rearranged fields during testing, the field IDs may no longer match the visual order of the questions in your form.
In this tutorial, we’ll show you how to reorder the survey questions by their question number using a simple PHP snippet.
Adding the Code Snippet
Use the snippet below to reorder questions on the Print Survey Report page so that they follow the order shown in your form builder.
If you need help adding custom code, please see our tutorial on adding code snippets.
/**
* Reorder WPForms Survey Questions on the Print Survey Report page.
*/
function wpforms_reorder_survey_print_report() {
// Check if we're on the Print Survey Report page.
if ( isset( $_GET['page'], $_GET['view'], $_GET['print'] ) && 'wpforms-entries' === $_GET['page'] && 'survey' === $_GET['view'] && '1' === $_GET['print'] ) {
?>
<script>
(function($) {
$(document).ready(function() {
// Function to perform the reordering.
function performReordering() {
var $container = $('#wpforms-survey-report');
if (!$container.length) return;
var $questions = $container.find('.question');
if (!$questions.length) return;
var questionsArray = [];
$questions.each(function(index) {
var $q = $(this);
var questionNumber = 9999; // Default high value
var $qNum = $q.find('.q-num');
if ($qNum.length) {
var qNumText = $qNum.text();
var match = qNumText.match(/Question\s+(\d+)/i);
if (match && match[1]) {
questionNumber = parseInt(match[1], 10);
}
}
questionsArray.push({
element: $q,
number: questionNumber,
originalIndex: index
});
});
questionsArray.sort(function(a, b) {
return a.number - b.number || a.originalIndex - b.originalIndex;
});
$questions.detach();
$.each(questionsArray, function(index, item) {
item.element.find('.q-num').text('Question ' + (index + 1));
$container.append(item.element);
});
}
performReordering();
});
})(jQuery);
</script>
<?php
}
}
add_action( 'admin_print_footer_scripts', 'wpforms_reorder_survey_print_report' );
When adding this snippet using the WPCode plugin or any other method, make sure to set the snippet’s Location to Admin Only. The code will not work if the location is set to any other options.

And that’s it! Now your survey results will appear in the same logical order as your form.