Use ENTER, not SHIFT+ENTER to Insert Line Break in WP editor

I would like to use ENTER button to insert line break, not SHIFT + ENTER by default. I added this code into function.php. It works but the problem is the text-align buttons are not working. When I click on any text align button, nothing happens. The text align buttons in Both Wordpress editor and TinyMCE Advance plugin editor are not working. But when I remove the code, it comes back normal. How can I solve this issue? /* Filter Tiny …
Category: Web

Wrap Meta Box with <li> and </li> for each new line

I'm trying to automate one of our posting aspects. We post a lot of lyrics and have a system of meta boxes which we use to input various pieces of information about each set of lyrics we post. One aspect that is a little annoying is having to search &amp; replace &lt;li&gt;&lt;/li&gt;tags to the start and end of each new line of lyrics. I was hoping to have PHP echo this automatically but my code is not working at the …
Category: Web

Line Breaks are stripped off when direction property is found

The line breaks are stripped off when the p tag has a dir attribute inserted, to explain further I'll list some examples. Let's say we have 2 lines of text as following &lt;p&gt;Text Paragraph Number One Goes Here&lt;/p&gt; &lt;p&gt;Text Paragraph Number Two Goes Here&lt;/p&gt; If I want to add line breaks between the two paragraphs it works fine to become like: &lt;p&gt;Text Paragraph Number One Goes Here&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Text Paragraph Number Two Goes Here&lt;/p&gt; However if …
Category: Web

How to break line / add <br> to ADMIN menu

Disclaimer: This question is not about &quot;frontend&quot; nav menu I am looking for a way how to break line in a menu item label in WP admin sidebar menu, sidereason is that the custom post type label I am registering is too long for 1 line and I don't really want to mess with the width of the admin menu. I tried adding both &quot;\n&quot; and &lt;br&gt; into the custom post type label, but &lt;br&gt; gets escaped and line breaks …
Category: Web

WordPress automatically removes line break

When writting a description for a Woocoomerce Product and inserting a line break with br or p Tag, WordPress automatically removes it. This is really annoying because on some points, i want to have a little line break. I often found the solution to install TinyMCE. After that now WordPress doesnt removes the p Tag anymore but inserts a &amp;nbsp inside of it and so the line break is way to big. So i want a line break like a …
Category: Web

How to get excerpt correctly formatted

I'm using a theme that use the_excerpt() function to show the excerpt of the post. All posts have not set custom excerpt, so the_excerpt() returns a piece of post content. In some post first paragraph contains a &lt;br&gt;, for example: &lt;p&gt;My new question is:&lt;br&gt;why words are not separated by a white space?&lt;/p&gt; The text rendered is: My new question is:why words are not separated by a white space? Following this post I implemented this solution: function my_excerpt($text = '', $raw_excerpt …
Category: Web

tinymce and responsive line-breaks (short words after a period)

With the advent of many different screensizes, manual line ending (not sentence-endings) has become a bit of a guessing/repetitive task. I want to avoid having the first short word of a new sentence on the ending of the line all by itself on smaller screens. After a period, at the start of a new sentence, is there a way to make 1, 2 or 3-letter words be followed automatically by a non-breaking-space instead of a normal space in tinymce?
Category: Web

Custom Fields displaying in single line

I have custom fields to display in a post. But all of the custom fields are displaying in a single continuous line, while i want them in separate lines. I am not a coder. I tried &lt;br&gt;, &lt;li&gt; but still no luck. I also searched in stack exchange and web for similar problem, but could not get answer. Please help. Below is the Code i have in single.php after - while ( have_posts() ) : the_post(); $key_name = get_post_custom_values ($key …
Category: Web

Removing line breaks when in text view with wp_editor

While working on a custom plugin, I needed to add the wp_editor in the admin to let the user add its own content. I want the user to be able to write custom rich texts with the "Visual" editor mode but I also want the user to be able to paste HTML codes in the "Text" view. For example, if he wants to paste his subscription HTML form, he could do that while switching to the "Text" mode. The issue …
Category: Web

Remove Line Breaks From Cell Content in WordPress

A line break in a table cell is converted to ⟨br ⁄ ⟩ when it is saved. I must remove all line breaks from the cell content else there is excessive space between paragraphs, list items, etc. It makes a large block of content harder to edit than it should be since it is all mushed together. Is there an option or a workaround to prevent the arbitrary insertion of ⟨br ⁄ ⟩’s in cell content? or is there a …
Category: Web

How to add JavaScript code on WordPress properly?

In the code editor, pasting: &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; var words = []; words.push('vocabulary'); words.push('lexicon'); words.push('lexicons'); &lt;/script&gt; will make it: &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt;&lt;br /&gt; var words = [];&lt;/p&gt; &lt;p&gt; words.push('vocabulary');&lt;br /&gt; words.push('lexicon');&lt;br /&gt; words.push('lexicons');&lt;/p&gt; &lt;p&gt; &lt;/script&gt; The version is 4.9.8. How should I add it properly? FYI: How to include jQuery correctly?
Category: Web

Show menu item description with line breaks

I have a problem with my theme... I use Agama, and i've checkmarked "description" in the menu settings, but it won't display it on the frontend, since the theme doesn't allow it. But then I found this function: function prefix_nav_description( $item_output, $item, $depth, $args ) { if ( !empty( $item-&gt;description ) ) { $item_output = str_replace( $args-&gt;link_after . '&lt;/a&gt;', '&lt;span class="menu-item-description"&gt;' . $item-&gt;description . '&lt;/span&gt;' . $args-&gt;link_after . '&lt;/a&gt;', $item_output ); } return $item_output; } add_filter( 'walker_nav_menu_start_el', 'prefix_nav_description', 10, 4 …
Category: Web

Wordpress blockquote removes `<br>` tag

So I have a quote in my page template and I would like to give the user the opportunity to add line breaks whenever they desire to do so. I wanted the blockquote to have an extra &lt;p&gt; tag inside the &lt;blockquote&gt; tag so I could style it better. The problem I'm having now is that the &lt;br /&gt; tags are being removed. While using the wpautop() function they should stay. Here is what I did: $matched = preg_match("~(?&lt;=&lt;blockquote&gt;)([\s\S]+?)(?=&lt;/blockquote&gt;)~", wpautop($child-&gt;post_content), …
Category: Web

Stop editor from removing <p> tags and replacing them with nbsp

When I enter content in posts/pages' WYSIWYG editor, I do not get &lt;p&gt; when ending paragraphs, just &amp;nbsps. If I manually place &lt;p&gt;&lt;/p&gt; in the HTML mode, they are stripped as soon as I switch to 'visual' mode. This is repeated in several sites (I thought it was the theme but it isn't). I have read dozens of topics and answers, but none solve my problem. I tried add/remove wpautop in my functions.php file but nothing helps. I do not …
Category: Web

Preserving tabs and line breaks in <pre><code> when switching from HTML to Visual Editor

Tabs placed in a &lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt; block are stripped and line breaks are removed leaving a single continuous line of text. This occurs when switching from html to visual editors. Is there a setting in TinyMCE to avoid this? BEFORE: AFTER: Here it even garbles the code and spits parts of it out the &lt;pre&gt;... EDIT: I seems the best option is to remove the &lt;code&gt; tag entirely and leave the pre. This still has the issue of removing duplicate blank …
Category: Web

How to show the contants in front end same as visual editor with space / linebreak?

My visual editor looks like this: My text editor looks like this: But my front end looks like this: I know that the wordpress automatically removes linebreaks. So I installed tineMCE advace editor and checked "stop removing &lt;p&gt; and &lt;br&gt; tags" on the plugin setting. After that line breaks were there. I saw the space. But it was adding &lt;p&gt; tag on every single line. It was so annoying. So I uninstalled the plugin. then I added these code snippets …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.