$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugins - TinyMCE Advanced newline problem|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - TinyMCE Advanced newline problem

matteradmin10PV0评论

I am using TinyMCE Advanced plugin according to qTranslate in a wordpress 3.3 installation. My question is: why does tinymce translate visual editor new line ("enter" key) in a <p>&nbsp;</p> instead of <br/>?

Is it possible to change this behavior?

I am using TinyMCE Advanced plugin according to qTranslate in a wordpress 3.3 installation. My question is: why does tinymce translate visual editor new line ("enter" key) in a <p>&nbsp;</p> instead of <br/>?

Is it possible to change this behavior?

Share Improve this question edited Feb 9, 2019 at 0:04 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Mar 7, 2012 at 14:46 frabiaccafrabiacca 2572 gold badges5 silver badges17 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 10

Go into Settings -> TinyMCE Advanced, and check the option Stop removing the <p> and <br /> tags when saving and show them in the HTML editor. This will allow you full control over those tags inside the HTML view.

For a single line break without overriding the editor, use Shift+Enter.

To override the editor and make Enter a single line break, put this into your functions.php:

function change_mce_options($init){
    $init["forced_root_block"] = false;
    $init["force_br_newlines"] = true;
    $init["force_p_newlines"] = false;
    $init["convert_newlines_to_brs"] = true;
    return $init;       
}
add_filter('tiny_mce_before_init','change_mce_options');

This does not convert shift+enter into <p></p> however, and this will cause some strange behavior for already existing content (if you're inside an existing <p> it will give two lines instead of one), so I would strongly recommend getting used to shift+enter instead.

1) use soft returns (shift+enter) to insert <br> instead of paragraphs.
2) if you want to make intent in the beginning of sentence after
(SHIFT+ENTER), then you may need to use this custom code: https://wordpress.stackexchange/a/139347/42702

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far