If you add handler for action with add_action
, you should call this with do_action
, but I does not see it. Also actions using in AJAX, simple POST/GET request is not need of
Simple example of form handling
<form method="POST" action="" class="my-form">
<input type="hidden" name="category" value="" />
<input type="hidden" name="action" value="recipe_filter" value="123" />
<input type="submit" />
</form>
// PHP somewhere like functions.php or this page exactly
<?php
if( ($_POST['action'] ?? '') == 'recipe_filter' ){
$value = empty($POST['category']) ? 'default value for category' : $POST['some'];
}
?>
JS
run $('form.my-form').submit()
when dropdown value is changed
Related Posts:
- WordPress Ajax always returns a 404 error
- Calling a method from functions.php on a click of a button
- Nice scroll to wordpress
- Javascript code inside “” in core WordPress files .php
- Minify HTML, CSS, JS with PHPWee?
- Slide in Panel WordPress Post
- Show post in slider
- Populate dropdown with Child Pages based on Parent Page chosen
- search and replace preword from author
- How to change redirection route to a php page for making it only accessible by logged-in members?
- parts of url disappear when using # inside href=”” [closed]
- Noscript not working as it should in wordpress site
- Add Codepen animation as Preloader to WordPress
- HTML escaping data with ajax requests
- Override user-edit.php to design own profile page
- Calling PHP Titles inside Javascript Markup
- Link to page with posts of specific type
- Replacing WordPress Icons (menu,icons32, etc)?
- Is it possible to isolate and use WordPress functions outside of wordpress
- Time Delay a URL Redirect for Specific Page
- Cascading dropdown select search based on Parent Page & Child Page
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Display WordPress search results based on the selected Sub-Category
- html form: redirect page after form completes submit function and posts data
- WordPress User Meta value variable into Google Gauge Chart
- Search bar for wp menu
- Adding HTML Code to Replace Text in PHP
- Executing php on button press
- Add other class content with reference class value
- Using Google Analytics in an enqueued JS file
- separate list of programs in html/javascript coming from php
- How to use wp_ajax_set_post_thumbnail?
- How do I disable cache for a certain page?
- WordPress Slider is not working
- Show subcategory name selected in specific category woocoommerce
- sessionStorage saves input value in browser but it is not loaded in the form field
- Collapsible menu on post sidebar only expands and does not collapse
- Target a specific container to style on WordPress storefront theme
- scroll scrpit to particular button position to next id when click button
- Bootstrap Carousel Indicators Won’t Cycle On Custom WordPress Theme
- Where to find the html for WordPress site? [closed]
- I need help implement a Javascript code into the PHP file
- Trying to customize wordpress drop down categories
- Is there a better way to output HTML as a shortcode?
- Load wp_editor on button click
- Slick slider not working on wordpress
- Pass media upload value to input field
- Blank on static home page?
- Where exactly do I write define( ‘WP_DEBUG’, true ) in wp-config file
- How to use a frontend URL with a Plugin
- How to display blog images using wordpress in existing project
- How to display a value from a radio button in the options menu in wordpress
- Custom image upload
- How to display recent posts on home page with custom HTML
- Upload Image in a WordPress page using PHP
- Bridging TinyMCE js and WordPress PHP?
- Trying to implement Ajax comments in WordPress, getting WP error
- Ajax – Call to undefined function get_option()
- Why the JavaScript code is ignored from wp editor?
- JS file work only in index page
- Integrating PHP into Javascript to display map markers with Google API – problem with wp_localize
- Why Won’t My Inputs in a form with a Get method work together?
- How to pass Select value from Javascript to PHP to generate select option on change
- How to get the value of input hidden html from text editor to custom page template?
- WordPress Scripts Being Loaded in Footer
- How to convert select to HTML with PHP tags inside of it [closed]
- php within html within php
- load ajax using admin-ajax.php
- php esc_html_e with an html link inside not working
- Using ob_start and ob_get_clean with wordpress shortcode
- Creating an image from a custom field
- WordPress forms submissions and PHP files
- Function Display article [closed]
- How to get the second slug of a page url?
- Load Javascript for a widget WordPress
- custom add note meta box with add button in wordpress
- duplicate posts with ajax load more wordpress
- How to populate a Gutenberg select field SelectControl with option value from PHP array
- Send an e-mail on address with the link with disliked post
- List sub categories and corresponding posts of a parent category
- population category dropdown and sub category onselect
- Fetch Data from an external MSSQL Database in a Managed WP hosting
- Add Link to PHP message
- Trying to add some custom text into WordPress Post title via function.php
- Adding extra data to shortcode attributes and pass it to JS with wp_localize_script
- How to Protect a private folder inside uploads folder, if User is not Logged In?
- Replacing entire tag with shortcode – JavaScript [duplicate]
- How do I make comment-reply-button with that takes to comment reply form on click
- How to make a parent page for author.php?
- How to load WP_Editor JS files manually (with AJAX)?
- Multisite – Display different header content based on which site is accessed
- html to posts, jpg to featured image, zip file contains jpg and html
- How to only fetch certain Tag ID’s
- Add title and caption to thumbnail image on mouseover
- How Can I Center the Logo in the Navigation Menu? [closed]
- Cannot get custom javascript to execute on page
- HTML in PHP problem [closed]
- How to create and add js and css file when server is not on my PC?
- Object of class WP_Post could not be converted to string while trying to console.log wp_get_nav_menu_items
- Check radio get value to array