2

WP 中的 TinyMCE 有一个很好的格式标签下拉列表,每个人都使用,但是有没有办法给这些标签添加一个类?例如,可以有 2 个<p>标签,一个生成基本标签,<p></p>另一个生成<p class="myclass"></p>.

4

1 回答 1

2

确实。如果你想弄脏 php,这里有一个教程:http : //wp.tutsplus.com/tutorials/theme-development/adding-custom-styles-in-wordpress-tinymce-editor/ 里面的内容这个过滤器:

add_filter( 'tiny_mce_before_init', 'tuts_mce_before_init' );
function tuts_mce_before_init( $settings ) {

    $style_formats = array(
        array(
            'title' => 'My Style',
            'selector' => 'p',
            'classes' => 'myclass',
        )
    );
    $settings['style_formats'] = json_encode( $style_formats );
    return $settings;
}

这是一个可以为您完成工作的插件: http ://wordpress.org/extend/plugins/tinymce-advanced/

于 2012-10-26T14:08:58.250 回答