• I’m using a theme that makes use of the tinymce accordion button in the editor. The accordion title is set as style header 2 (h2.acc_title), and I’m wanting to change it to h4.
    The reason: we generate ‘printview’ from our pages and posts and from there users can generate a PDF. When this happens, the ‘bookmarks’ in the PDF are created from the header styles and the accordion header style messes the bookmarks up.

    I’m told the accordion function comes from tinymce/accordion.php, but I have absolutely no idea how to make the change so that instead of h2.acc_title it becomes h4.acc_title.

    Any help would be much appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    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.

    Thread Starter Jon Fergus

    (@jon-fergus)

    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?

    Moderator bcworkz

    (@bcworkz)

    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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘TinyMCE Accordion’ is closed to new replies.