I can’t find anything on this anywhere. Probably looking for the wrong thing. I’m trying to make a button change dynamic data and do some other custom stuff/checks with PHP. Namely a voting system- if you press the button, the dynamic data field should go up one for the post you’re on. How can I achieve this?
For reference, if you already voted, you shouldn’t be able to vote again (hence why I was trying to use PHP) but I can’t figure out how to get a button to run PHP when pressed. Any ideas?
If you want to avoid reloading the page upon voting, you’ll need to use AJAX. You can call your PHP script with the fetch() function. After voting, you can set a local storage key or a cookie to prevent users from voting multiple times.
Did some looking up and found some good cursory information; how would fetch() play into this- looks like a PHP function? Would this be with do_action() or something like that?