Short: You can’t. Php functions can’t be run “straight” from a button because they run server side. You need either to set a $_POST or $_GET (so you can run the function on the page load) or use ajax/javascript.
You can find multiple answers to this question on the site already. For example this. edit: button/link, doesn’t matter.
Related Posts:
- Get a list of all registered actions
- How can I force a file download in the WordPress backend?
- How to implement a customizable free OpenID authentication?
- What’s a reliable way to depend on another plugin?
- Woocommerce get cart total price in a number format [closed]
- Woocommerce – Hide “add to cart” on free products
- Is it good practice to remove redundant plugins and themes?
- How to hide /wp-content/uploads/ from URL?
- Add image to post from external URL
- User profiles and object associations
- Generate Advanced Custom Fields box in custom admin menu page
- Share buttons on article footer
- WordPress plugin search does not work and updates are not shown, VPS install
- How to prepend to the_title for admin-side plugin’s use
- Custom data-id wp_enqueue_script
- Whats the difference between Page Builder Plugins and Theme Builder Softwares? [closed]
- Settings API – input always updates over validation
- Creating search filter through plugin
- Should I host support forum on wordpress.org or my own website?
- How to setup a Network Plugin across the network with only my settings?
- jQuery Plugin to use WordPress functions in AJAX request
- Is it possible to insert images directly from the server?
- Can a plugin deactivate itself?
- “Members only” section of a WordPress site – self signup and no backend access
- I have functions in my wordpress plugin. How do I get them to work for me?
- Display content from custom post type if match to main post category
- How to embed HTML code from WP Coder plugin (or other) into Main Index Template of the theme
- Which escape function to use when escaping an email or plain text?
- Wp List Table – wpdb results are not displaying
- Adding widgets to header and footer from plugin
- SEO smart plugin not working for words ending with ä, ö, å
- resetting permalinks after changing page names
- Edit Yoast SEO breadcrumbs output [closed]
- WordPress WPforms customization
- Admin accounts unable to see plugins from external IP
- WP ALL Import plugin – import data from certain ids
- Hide Elementor Templates Menu from Admin [closed]
- Where these .js file come to source code?
- How to remove plugin metaboxes from edit.php
- creating a custom shop page display on archive woocommerce
- How to delete all trashed item in one-go
- How to update mu-plugin
- Edit Permalink Structure For Custom Post Type or Modify .htaccess?
- Hide a Menu Item on Login
- What are the performance hiccups when building plugins?
- disabling ftp on wordpress
- Where is my google maps on my page? [closed]
- coding a WordPress AJAX Form using PHP to check if User is Logged Out and Show error
- plugin wraps the entire content
- how to add custom info on author page? plugin, child theme?
- How Do I Uninstall a Current WordPress Theme and Install a Fresh Theme
- How to add HTML5 required on wp_editor
- Individual Comment Notification Setting For Post Author
- Nonce failing with second argument
- Mass Mail Plugin to Email Specified User Roles [closed]
- Favorite recent post widget
- Woo-commerce Update price as a Bulk from My offline software export
- co-authors plugin – inline listing
- require_once not working in plugin wordpress
- Quiz with complex output/result
- Using Class loader in WordPress boilerplate
- Identify User Language, Redirect to the corresponding page and Save the chosen language as Cookie
- Display value of the GET parameter in a new URL page
- How do I use a plugin’s shortcode attribute value in another function?
- Change the address of the music player if not available
- Hello everyone! Is there a function to call the wordpress loader?
- $wpdb->insert not working inside save_post tag
- How to check for already existing plugin versions on activation? and prevent errors
- update_post_meta is not working for me when I use e.preventDefault for update button
- Securing langugae folder
- Use modulo condition in ACF repeater Field
- jQuery works instead of $
- How to get data from a private API and add it to wordpress pages
- Debug in WP backend
- Geotargeting plugins never work
- How to get custom or filtered endpoints in WordPress API?
- add_external_rule – rules deleted when visiting permalinks page
- Change pages based on city
- WordPress 4.1 plugin only save 1 field to database
- How to run my plugin only when the whole page is sent?
- Setup SMTP setting in wordpress
- Get page type to display content
- Insert data in custom table during new post creation
- Widget redirecting to home page
- Advanced Custom Fields Plugin – not displaying images
- Notification When Post Approved
- Meta Box plugin image_advanced not showing up on frontend
- Creating Features List in WordPress Post
- why i cannot see some plugins while they are enabled on network admin page?
- I am using multi image metabox plugin but I did get how to display the images in templete?
- WooCommerce Email Customization
- SSL not working for checkout
- How to open author url linked to a new tab in settings page in the WordPress plugin list
- Change page content based on dropdown selection
- How can I properly sanitize the update_option in WordPress?
- My Blog page ( posts page ) theme isn’t changing with the new theme [closed]
- Why is my menu page not being displayed?
- Ajax Called in Plugin php file
- Store large dataset in WordPress installation temporary
- How to edit the name of a plugin on wordpress.org/plugins