2013-08-16 107 views
0

我使用的是wordpress 3.6和高級自定義字段插件4.2.1。Wordpress the_content();顯示內容和附件

先進的自定義字段設置 - https://dl.dropboxusercontent.com/u/15109395/q/acf-media.png

我的帖子 - https://dl.dropboxusercontent.com/u/15109395/q/page-content.png

我的單頁代碼

<section id="contentLeft" class="single"> 
    <?php if (have_posts()) { the_post(); the_content(); }?> 
</section> 

結果 - https://dl.dropboxusercontent.com/u/15109395/q/page-front.png

,但我不希望添加圖像在內容區域。我的本地安裝沒有問題。不顯示附件。但我的活網站顯示附件上傳到該帖子。 我該如何解決這個問題?請幫幫我。謝謝。

回答

0

,如果你想從所有文章和頁面,簡單的複製刪除圖片下面的代碼到你的主題functions.php

<?php 
function remove_images($content) { 
    $postOutput = preg_replace('/<img[^>]+./','', $content); 
    return $postOutput; 
} 
add_filter('the_content', 'remove_images', 100); 
?> 

它會刪除的圖像無論the_content()有圖像

其他你需要包括這在以下代碼中輸入:

<?php remove_filter('the_content', 'remove_images'); ?> 
+0

謝謝。但那不是一個完美的解決方案。該功能刪除插入的圖像。我不想在the_content()函數上附加圖像。但我想在內容區域插入iamge。你有什麼建議嗎? –

+0

你是什麼意思的附加圖像?是特色圖片? –

+0

找到原因。 http://wordpress.org/support/topic/thumbnails-magically-appearing-on-all-pages。謝謝。 –