2017-06-10 49 views
1

我已經創建了具有表單的自定義帖子類型,供用戶編輯內容。在「編輯內容」表單中,我想隱藏正在顯示的
標籤。我已插入以下 - 但它似乎沒有要在自定義後類型的表格內工作:隱藏</br>來自Wordpress中自定義發佈內容的標籤

remove_filter('the_content', 'wpautop'); 
remove_filter('the_excerpt', 'wpautop'); 

function wpse_wpautop_nobr($content) { 
    return wpautop($content, false); 
} 

add_filter('the_content', 'wpse_wpautop_nobr'); 
add_filter('the_excerpt', 'wpse_wpautop_nobr'); 

這是包含在
標籤出現在內容自定義文章類型表:

<table class="tg"> 
 
    <tr> 
 
    <th class="tg-031e"><strong>[cred_field field='supplier-1' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    <th class="tg-031e"><strong>[cred_field field='supplier-2' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    <th class="tg-031e"><strong>[cred_field field='supplier-3' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    <th class="tg-031e"><strong>[cred_field field='supplier-4' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    <th class="tg-031e"><strong>[cred_field field='supplier-5' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    <th class="tg-031e"><strong>[cred_field field='supplier-6' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    <th class="tg-yw4l"><strong>[cred_field field='supplier-7' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    <th class="tg-yw4l"><strong>[cred_field field='supplier-8' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    <th class="tg-yw4l"><strong>[cred_field field='supplier-9' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    <th class="tg-yw4l"><strong>[cred_field field='supplier-10' post='charity' value='' urlparam='' ‘placeholder’='Supplier Name']</strong></th> 
 
    </tr> 
 
    <tr> 
 
    <td class="tg-6wtj">[cred_field field='items-column-1' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    <td class="tg-6wtj">[cred_field field='items-column-2' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    <td class="tg-6wtj">[cred_field field='items-column-3' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    <td class="tg-6wtj">[cred_field field='items-column-4' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    <td class="tg-6wtj">[cred_field field='items-column-5' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    <td class="tg-6wtj">[cred_field field='items-column-6' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    <td class="tg-7uzy">[cred_field field='items-column-7' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    <td class="tg-7uzy">[cred_field field='items-column-8' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    <td class="tg-7uzy">[cred_field field='items-column-9' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    <td class="tg-7uzy">[cred_field field='items-column-10' post='charity' value='' urlparam='' ‘placeholder’='Items Needed']</td> 
 
    </tr> 
 
</table>

Link to Website

Screenshot of br tags

+0

哪裏BR標籤? – orabis

+0

@orabis我添加了一個屏幕截圖,顯示這些標籤的顯示位置 - 因爲您需要登錄才能看到它 – user165498

回答

0

我會假設你需要的是使你的文本內容不被忽視。一個簡單的方法來做到這一點是如下

var div = document.createElement("div"); 
div.innerHTML = yourPost; 
var unescaped= div.innerText|| div.textContent; 

更新的解決方案: 如果你是OK使用jQuery,這裏是剝離BR標籤的簡單方法。簡單地說,你會如下得到text內容這個網站的文本(測試是您當前的字符串,str是輸出你正在尋找):

var test= "Test <br> test"; 
var str = $("<span>"+test+"</span>").text(); //"Test test" 
+0

我已將此插入到我的functions.php中 - 但br標籤仍然可見:( – user165498

+0

您使用了「未轉義「value? – orabis

+0

我不確定我是否正確使用了它,請確認在添加此代碼時使用的步驟並實現它? – user165498