【问题标题】:Wordpress the_content(); showing content and attachementsWordpress the_content();显示内容和附件
【发布时间】:2013-08-17 16:01:20
【问题描述】:

我正在使用 wordpress 3.6 和高级自定义字段插件 4.2.1。

高级自定义字段设置 - 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

但是,我不希望在内容区域中显示该附件图像。我的本地安装没有问题。不显示附件。但我的现场网站显示上传到该帖子的附件。 我该如何解决这个问题?请帮我。谢谢。

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    这个解决方案解决了我的问题。谢谢。 http://wordpress.org/support/topic/thumbnails-magically-appearing-on-all-pages

    【讨论】:

      【解决方案2】:

      如果您想从所有帖子和页面中删除图片,只需将以下代码复制到您的主题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' ); ?>
      

      【讨论】:

      • 谢谢。但这不是一个完美的解决方案。该功能删除插入的图像。我不想在 the_content() 函数上添加附件图像。但我想在内容区域插入 iamge。你有什么建议吗?
      • 附加图片是什么意思?是特色图片吗?
      • 找到原因。 wordpress.org/support/topic/… 。谢谢。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-06
      • 1970-01-01
      相关资源
      最近更新 更多