skip to Main Content

I have a CPT of Hotels in my WordPress Website, and I have a specific footer for this CPT (i.e. applies to all hotels), which contains a contact form.

Currently, when a user send me an email I don’t know from which hotel this email came from.

How could I interactively add some dynamic text to the message that I could identify the hotel (for example, showing me the page title, or the page link in which the form was sent).

2

Answers


  1. Follow these steps:

    1. Set the form “id” to “hotel-reservation”.
    2. Add a hidden input to your form and set the id to “reference”.
    3. Add this js code to your global javascript:

      jQuery( document ).ready(function() {
      
         $("#hotel-reservation").submit(function(){
            $('input#reference').val( $(location).attr('href') );
         });
      });
      
    Login or Signup to reply.
  2. Is the form hard-coded? You could use a hidden field within the form with value="<?php the_permalink(); ?>" or <?php the_title(); ?>

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search