我正在寻找解决方案,该方法如何在Wysiwyg编辑器中为我的ul列表设置类。
我实现了类似的方式:
add_filter('wp_insert_post_data', 'my_add_ul_class_on_insert');
function my_add_ul_class_on_insert( $postarr ) {
$postarr['post_content'] = str_replace('<ul>', '<ul class="my-custom-class-ul">', $postarr['post_content'] );
$postarr['post_content'] = str_replace('<li>', '<li class="my-custom-class-li">', $postarr['post_content'] );
return $postarr;
}
但是它不起作用。有什么想法吗?感谢您的任何建议。