admin管理员组文章数量:1318336
I'd like a specific menu item to have more spaces between words.
For example: Word Word
Needs to be: Word Word
In the menu editor, WP strips-out any additional spaces added with the spacebar or using the HTML code
.
What's the next most efficient method?
I'd like a specific menu item to have more spaces between words.
For example: Word Word
Needs to be: Word Word
In the menu editor, WP strips-out any additional spaces added with the spacebar or using the HTML code
.
What's the next most efficient method?
Share Improve this question asked Oct 1, 2018 at 2:09 KalnodeKalnode 2261 silver badge11 bronze badges 1 |2 Answers
Reset to default 2Previously I assumed WP would strip HTML, so I never tried it.
The HTML below works like a charm, using the WP menu editor:
Word <span style="margin-left: 20px;"> </span> Word
(however, inputting
didn't)
Alternatively, the CSS trick mentioned by Jacob and Linda would work well too:
word-spacing: 3px;
My menu item actually has 4 words, and I just needed to increase the middle spacing.
In the end, it's nice avoiding a PHP function or JS client-side. I just wonder is there any issue down the line having HTML in my menu title. Other than my menu rendering in the page layout, I can't think of where else I may output the menu items to.
One of the options in the wp_nav_menu function is whether to preserve whitespace. The default is that it’s preserved, but perhaps your theme has it set to discard?
https://developer.wordpress/reference/functions/wp_nav_menu/ 'item_spacing' (string) Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'. Default 'preserve'.
You could also add a CSS class to just that one menu item and use the word-spacing property to give the appearance of more spaces: https://developer.mozilla/en-US/docs/Web/CSS/word-spacing
本文标签: Inserting additional ampnbsp into menu item text
版权声明:本文标题:Inserting additional &nbsp; into menu item text 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742042469a2417611.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
word-spacing
property. – Jacob Peattie Commented Oct 1, 2018 at 2:44