2017-10-06 37 views
0

展望放在同一行/列的圖形作爲H3標題是這樣的:創建WordPress的簡碼,禁用wpautop()上包裹的內容嗎?

<h3 style="display:inline;">Graphic Advantage</h3><img style="max-width: 50px; width: 100%;" src="https://sgdesign.com/images/SGDadvantage.png" alt="SGD Advantage" /> 

首先,我讓H3顯示=直列所以它僅佔它的實際寬度,而不是整行。我可以浮在H3和圖形左邊,然後做一個clearfix但似乎過度。目標是簡單地將h3和小圖形放在同一行上。

它失敗,因爲Wordpresses自動格式化功能wpautop(),它自動地設置,一個段落標籤<的p>

但尚未當二次內容(圖形)被包裹在一個短碼工作的:

<h3 style="display: inline;">Advantage SGDesign</h3> 
[tooltip text="Throughout our site you'll see this icon that will help identify significant differences between SGDesign and other companies"]<img style="max-width: 50px; width: 100%;" src="https://sgdesign.com/images/SGDadvantage.png" alt="SGD Advantage" />[/tooltip] 

問題:最佳實踐以某種類型的包裹標籤內挫敗wpautop()函數?

也許創建一個空的簡碼像

function no_wp_autoformat_shortcode() { 
return null; 
} 
add_shortcode('nowpautop', 'no_wp_autoformat_shortcode'); 

這是可行的,但現在它隱藏在包裹< IMG ...

所以,問題變爲如何使圖像顯示在被包裹短代碼 ?

<h3 style="display:inline;">Graphic Advantage</h3>[nowpautop]<img style="max-width: 50px; width: 100%;" src="https://sgdesign.com/images/SGDadvantage.png" alt="SGD Advantage" />[/nowpautop] 

回答

0

有辦法阻止WordPress的編輯器中使用remove_filter('the_content', 'wpautop');<p>元素自動添加。當涉及到的分段文本這樣做的不好的一面將禁用所有在WordPress這是不好的<p>元素。 (它也變得有問題,當人們截斷並從Word文檔粘貼文本...)

是使用簡碼,似乎對我的好,而不必重寫WordPress的核心功能

+0

是的,我已經閱讀如何停止自動格式化,寧願不失去功能,從而試圖找出如何寫一個短代碼實現了比包裝之外的元素空效果。 – Burndogz