How to redirect to a page after submitting form data?

Form handling needs to happen in functions.php (or equivalent) so that it triggers before headers are sent. Here is the how I achieved redirection after form submit: add_action(‘init’, ‘redirectAfterSubmit’); function redirectAfterSubmit() { if (isset($_POST[“submit”])) { insert_row(); wp_redirect( “/thank-you”, 301 ); die(); } } function insert_row(){ // form handing here }

Get count of rows based if column exists in two different tables

You need to use a join in your mysql query. Something like this might get you closer… global $wpdb; $rsvp_table = $wpdb->prefix . ‘rsvp’; $invites_table = $wpdb->prefix . ‘invites’; $sql=”SELECT COUNT(*) as count FROM $invites_table i1 JOIN $rsvp_table r1 ON (r1.reference = i1.reference)”; $yet_to_respond = $wpdb->get_results( $sql ); echo $yet_to_respond->count;

inner-wrap div pushing custom table far down on page

Part of the problem is that you’re running (or re-running) get_header() after your table, thus putting all of the header content into the body of page after the table HTML has started. <?php /* Template Name: Custom Table Is this part even needed for you? If this is a complete template, then probably, but if … Read more