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:
- How to enable suggested edits?
- How to change a user’s password programatically
- Cannot install plugins even though www-data has write permissions
- How to delete custom taxonomy terms in plugin’s uninstall.php?
- To Disable WordPress Rest API or Not To Disable?
- Does wordpress have a post hit counter?
- How to call a plugin function from front end form
- Get URL of a specific file
- Building a plugin that doesn’t break when deactivated
- translation does not work with text_domain
- Get subcategories with JSON API plugin
- Custom url structure for custom template
- WooCommerce plugin appearance and look [closed]
- adding a text message beside the comment submit button
- Overide a function that is inside a plugin
- If I delete plugins via FTP are settings kept in DB?
- Many plugins making WordPress run slow by design?
- Remove caching from wp_remote_get calls from custom plugin
- Transient unique names
- Hook into and send mail using WP Mail SMTP type plugin from HTML static front page?
- Missing Argument
- load_plugin_textdomain error
- W3 Total cache “empty all caches” and no stylesheets render [closed]
- Woocommerce pagination problem
- Can’t delete Draft Post [closed]
- Looking for a way that will collect visitors emails before letting them view the blog posts [closed]
- Why am I getting ( WooCommerce Services could not be installed (Could not create directory.). ) error and how to solve it ?
- How can i get the post’s full html source by its ID?
- Redux Framework: Page freezes on typing in Editor
- How can I inject options into an select tag inside the widget form?
- WordPress user account activation
- Init plugin again after ajax call finish
- Redirect to another page using contact form 7? [closed]
- Batch update of WordPress Plugins
- WooCommerce: Disable Taxation for Specific Address [closed]
- Separate database for a wordpress plugin
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Login problem after installing my written plugin [closed]
- Can deactivating a plugin sometimes “reset” settings within that plugin?
- remove all submenus from plugin
- Specific way to allow WordPress users to view their current password? And edit it?
- Is there a function to list all uploaded images? How can I add one?
- Plugin Admin Menu Boiler Plate
- How use wp media upload liberary in react components?
- WordPress permissions error with admin account
- site url is not working after migrtaion in worpress, all links are broken
- How to render a template file using shortcode inside a plugin
- How to add slides (images) to bxslider?
- Delete data from custom table when deleting a post
- If I use an alternative login (e.g. CAS or other SSO) plugin, is my site protected from the recent brute force login attempts?
- Pdf visualiser embedded into wordpress website
- How to deactivate my plugin upon deactivation of NextGen
- WP Insert Post If user refreshes override new post
- Problems with jQuery and is_admin()
- Simple sildeshow/image-upload plugin?
- How to hide particular plain text with link from different subscribers
- Manualy Updated WordPress Error
- Can I add Short Code Of A Plugin In The Code Editor of WordPress?
- How to uncheck this automatically from all wordpress posts?
- My wordpress blog posts page is broken
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Cron job shedules replace?
- fetch price from different table woocommerce
- WordPress show descriptions under images in gallery
- Cannot save a custom meta field in quick edit
- Simulate Update User button click
- Disable plugin for administrator
- ACF Query result in a new td (echo)
- Delete user meta based on key value that is an array
- Modify Plugin PHP Class in Child Theme – Correct Method
- Hook on widget context plugin to add custom context for widget
- mailjet plugin – extend functionnalities and reuse api
- Customize a widget position
- Using permalinks with parameters
- How to add featured image on front end form?
- Can’t get paramaters from url page of content
- twitter widget loads properly in all themes except my own theme?
- Where does the code to add a lightbox effect go?
- How to retrieve hashtaged tweets from a list of users and post to WordPress
- Using a Cron Job to dynamically populate a field ONCE, and then making the field blank the next time someone visits page
- How to create and use Custom hooks
- Custom Function for SEO by Yoast plugin
- Adding Relevant Post Images
- Custom feed parameters / Template overriding
- wordpress select multiple options and illegal string offset ‘timeslot’ [closed]
- post_exists() returns a 0 but the 0 doesn’t register [closed]
- Creating Event Builder Plugin [closed]
- How Do I Add Product Pictures To Search Results Of A Custom WordPress Theme Using A WooCommerce
- WordPress Plugin to for moving home page slideshow? [closed]
- Custom gutenberg block image preview not working
- WordPress Feature – Multi Level sorting
- De-index plugin files
- Update Plugin of wordpress to specific version
- Can WordPress updates take down site functions?
- How to get custom setting from get_option and pass it in getEntityRecords in gutenberg block?
- Learn from Other site [closed]
- Gravityforms login form custom redirect if form not submitted
- WordPress hack code issue, help required
- How to move a post in Vacancies so it appears in News/Events?
- Can’t install plugins