It’s very poor practice to edit core files to meet your needs. I think you should find a filter to hook that fires on new or edited posts & pages. Maybe ‘transition_post_status’? Then you just need a search and replace function that only changes h2 to h4 for the accordion title, while leaving any other h2s alone.
Thanks for the reply. That sounds like it could be a much better solution. It’s beyond my capabilities and understanding to implement though. But I’m willing to spend the time learning, if you can point me in the right direction or help get me started. How would I go about setting something like this up?
There’s lots of examples of how to hook into filters and actions. You write your function, then reference it using add_filter() or add_action(). You’ll need to look at the code that initiates the filter or action (using do_action() or apply_filters()) to determine what info is passed to your function. You hook function must return the first parameter, altered or not.
I implied in my previous post that ‘transition_post_status’ was a filter, but it is actually an action. Anyway, all your code can be placed in either a plugin, your theme, or a child theme. There’s info on creating plugins and child themes in the Codex, it can be fairly simple.
The advantage of plugin or child theme is your code is preserved anytime there’s an update of WP or your theme. Certain things can only be done in plugins, other things only in themes or child themes. For changing header tags, you can go either way.
In general, this is a good learning project. It’ll take a while to figure everything out, but in the end, you’ll find it’s relatively straight forward. Your biggest problem may be in figuring out which combination of old and new status transitions exist, and which ones you need to address, and which to pass thru unaltered.
Learning some PHP and WP hacking skills will be well worth the time investment IMO. Good luck and have fun!