You need to register the query var so it doesn’t get stripped by WP. Add this to your functions.php file.
function foo_add_query_var($vars) {
$vars[] = 'discount';
return $vars;
}
add_filter('query_vars', 'foo_add_query_var');
To call this in your template, simply use the following:
$discount = get_query_var('discount');
Related Posts:
- How to stop form resubmission on page refresh
- How to correctly submit a search form and display the result in an independent page
- add_filter the_content str_replace after shortcode
- Metabox repeating fields – radio buttons not saving correctly
- How to exclude pages from the search results
- How to insert PHP code in a WordPress Post
- How to handle a custom form in wordpress to submit to another page?
- Creating wordpress user registration form
- Creating a WordPress form with a PHP script and default header
- Submitting form via admin-post.php and handling errors
- Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB
- Processing a subscription form with POST method?
- How to group 2 radio buttons in a widget?
- Ajax form submit within a Post Metabox
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- Upload Image in a WordPress page using PHP
- Using Multiple Submit buttons to trigger customised php functions
- Get Admin Email Address From External PHP page
- Adding Custom Forms
- How to create a form and display its content as table in admin panel?
- My form action url is being prepended with a directory that does not exists
- How can I reuse the code to capture a param in a URL and place in a value in a hidden form?
- How to limit the number of forgot password reset attempts in WordPress?
- Post + form + action + results on the same page
- Ajax call return 404
- How to pre populate a form field with a link of a current user’s author profile?
- Why Won’t My Inputs in a form with a Get method work together?
- How to get the value of input hidden html from text editor to custom page template?
- Show success or error messages in Ajax response to WordPress custom registration form
- Contact form won’t submit
- wp_mail file attachment not being placed in upload folder?
- Form Security: nonce vs. jQuery
- Trying do build a contact form
- User register hook is not working in woocomerce register form
- How to execute html code inside php?
- Can a page contain php code?
- How to send form data from WordPress (Meta Box) to an OData service?
- What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?
- Form Submission Not Working In Custom Theme
- Why does my user not get added to the database on custom registration?
- How to add post meta in while loop?
- How to set cookies
- PHP Contact form
- Get wp_current_user_id using PHP and MySQL
- Adding Additional Variables on Menus Page
- PHP- Why is my contact form keep showing it is invalid? [closed]
- Simple php in wordpress widget [closed]
- form $_post action value gets truncated after it passes through two forms
- Adding data to custom wordpress database table
- Make a page (url) not cacheable [closed]
- Display multi-select box choices in a bullet list [closed]
- What should I write in the post action of this front end post form?
- Custom forms with HTML
- Contact form – problem with displaying message about sent mail
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- WordPress Custom Form – Getting Query Vars, Weird Glitch?
- $_POST returning empty values
- Trying to update Woocommerce meta values
- How to send custom form submissions to WordPress Database?
- Custom PHP form needs refresh to load page correctly
- Form from within a page
- I want it to detect the duplicate comment and give a warning on the same page
- I want to retrieve the email or username data entered for password reset, but failed. how can I do it?
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Confuse between forms and tables
- wordpress contact form messages not sending although it saying they were sent successfully with this php code
- Using a PHP form, get the page title or any other element in the sent e-mail
- form submission reverts to index.php template
- custom search query database in child theme
- Creating a WordPress addon for ContactForm7 submission (.XML file export)
- Using transients to store form notifications
- Insert data from form to database
- not able to access $_POST on backend profile update
- Custom Plugin Develoment, Form Action
- wordpress form action page not found
- Adding action item to admin users table and sending email
- Trouble with checked() for array of multiple checkboxes
- Custom HTML form using PHP – help with ajax/username validation
- Form direction to .php on localhost
- Form not working as it should in WordPress, but in a normal HTML site it does
- Ajax call URL 404’ing when pushed to staging server
- Update only some custom user fields
- Passed variable gets undefined variable error on insert on next page
- How to set up an auto delete post?
- Dynamic form variables for post meta
- Trying to display user meta by “name” – not by “ID”
- Headers for Contact Form are wrong
- Display default WordPress login/registration form into a modal window
- Trouble using wordpress functions in a pop-up modal form
- custom contact form no longer working (because of 3.2?)
- Correct Syntax for uploading files to custom directory in WordPress
- ajax form function error
- HOW TO Insert Existing PHP Code to WOrdPress
- Send foreach $_post method to contact form 7 [closed]
- php inside HTML via shortcode? [closed]
- Where to put include php file?
- Use HTML Form Data in PHP Function – WordPress Admin Page
- Contact form with dynamic dropdown and filter
- Custom form that stores data in mysql database
- Putting form result in my database