We all started out noobs at some time, it’s never too late to start learning ??
The solution isn’t too simple I’m afraid. Content entered in the editor gets passed through several filters when the post is saved, one of which is the one responsible for only allowing certain attributes in HTML. I don’t remember it’s name off the top of my head, if that can be determined, you could add plugin or functions.php code to remove that filter.
Removal may not be the best solution though, the filter does provide an important layer of security by stopping malicious code injection. Unfortunately it also blocks desirable code ??
Another way around this is to create a custom page template where the template provides the button image code, and displays whatever other form content above that that you are able to enter in the editor. This does require the entry be a page post type and not a regular post. I suspect you are doing this anyway.
There is a plugin that allows you to define arbitrary PHP code as a shortcode, then you could just enter [my-button]
or whatever in the editor and that shortcode will be replaced by the actual PHP output when the page loads. Unfortunately, that plugin is no longer supported, but it’ll probably work for now.
It’s not super difficult to directly define your own shortcode handler in your plugin or functions.php (of a child theme I hope) without the plugin, but there is a learning curve. You’ll probably struggle through creating your first shortcode, but then you will soon be easily creating others without much thought. This means you can just type [my-shortcode]
or something in your editor and any amount of PHP will be executed when the page is loaded, the output replacing the shortcode entry.
There’s also ways to pass parameters in shortcodes so you have complete control over what the code does. All things being equal, I would recommend shortcodes as a solution, but there is that learning curve. If you’re willing (and not in a big hurry), I’m willing to help you out.
The custom template solution is easier to setup, so something to consider given your experience. The filter removal is the easiest once we figure out the correct filter, but I’m reluctant to offer that as a solution.
Let me know what has the most appeal and I’ll get you started in the right direction, though searching the Codex will get you started too. I’ll still be here if (when?) you get stuck.