我正在创建一个使用wordpress作为CMS的多语言网站 .
我正在使用qTranslate插件来支持多语言 . 一旦启用插件,文本的所有格式都将丢失 . 即编辑器中的所有段落都合并为一个段落 .
我在设置中启用了此选项:“WordPress应自动更正无效嵌套的XHTML”,但没有任何更改 .
有什么建议吗?
在 wp-content\themes\your-theme-name\functions.php 末尾添加此代码:
//************************** PATCH START ***************************** // Fix for qTranslate plugin (that does not retain formatting in pages) if('html' != wp_default_editor()) { remove_filter('the_editor_content', 'wp_richedit_pre'); add_filter('the_editor_content', 'wp_htmledit_pre'); } remove_filter( 'the_content', 'wpautop' ); if ( ! function_exists('tmce_replace') ) { function tmce_replace() { $tadv_options = get_option('tadv_options', array()); $tadv_plugins = get_option('tadv_plugins', array()); ?> <script type="text/javascript"> if ( typeof(jQuery) != 'undefined' ) { jQuery('body').bind('afterPreWpautop', function(e, o){ o.data = o.unfiltered .replace(/caption\]\ +?<\/object>/g, function(a) { return a.replace(/[\r\n]+/g, ' '); }); }).bind('afterWpautop', function(e, o){ o.data = o.unfiltered; }); } </script> <?php } add_action( 'after_wp_tiny_mce', 'tmce_replace' ); } function teslina_tinymce_config( $init ) { $init['remove_linebreaks'] = false; $init['apply_source_formatting'] = true; $init['preformatted'] = true; $init['remove_redundant_brs'] = false; return $init; } add_filter('tiny_mce_before_init', 'teslina_tinymce_config'); //************************** PATCH END *******************************
在html模式下编写简单的帖子来测试如下:
<p>lorem</p> <p>ipsum</p>
在wordpress中有过滤器来格式化文本(插件或者functions.php)尝试找到它们,否则尝试另一个像Polylang这样的插件 .
我在这里找到了一个解决方案:http://www.teslina.com/en/748/wordpress/qtranslate-code-syntax-bugfix/
但是我怀疑插件中添加的代码在更新时会被删除 .
3 回答
在 wp-content\themes\your-theme-name\functions.php 末尾添加此代码:
在html模式下编写简单的帖子来测试如下:
在wordpress中有过滤器来格式化文本(插件或者functions.php)尝试找到它们,否则尝试另一个像Polylang这样的插件 .
我在这里找到了一个解决方案:http://www.teslina.com/en/748/wordpress/qtranslate-code-syntax-bugfix/
但是我怀疑插件中添加的代码在更新时会被删除 .