Add class to h1-tag (into formatselect) – TinyMCE / WordPress

I would like to add a class to my “formatselect” options of the tinyMCE in WordPress. So when selecting a h1 from the dopdown it should generate a <h1 class="blue">.

I found this Post, but can’t get it to work.

Read More

Any ideas?

Thanks in advance!

Related posts

Leave a Reply

1 comment

  1. What is described there is working even though not suitable for everyone. I’ll give you a short list of what you need to do:

    1. use the content_css tinmce init setting

    content_css: "http://www.mydomain.com/css/content.css",
    

    2. Create a content.css file containing your class

    h1.foo {
        background-color: #F067A0;
    }
    

    3. use the styleformatting tinmce init setting

    style_formats: [{
      title: 'My Foo styles'
      }, {
     title: 'Foo',
      block: 'h1',
      classes: 'foo',
      exact: true
    ,
    

    4. Make sure you have the style button included (tinymce init)

    theme_advanced_buttons1: "styleselect",
    

    You should be able to select text from the h1-tag in the editor and select foo from the dropdown menu of styles. The class should be applied to your selected text.