在wordpress插件上使用the_content钩子

Miquel Correa卡萨布兰卡

我正在尝试在wordpress的每一页中添加具有某些内容的div。为此,我正在尝试创建一个插件,以将该div添加到过滤器中。我已经创建了插件,用于修改内容的函数以及带有钩子“ the_content”的对该过滤器的调用:

function add_content_filter($content){

      $original_content = $content ; // preserve the original ...
      $add_pre_content =  '<p> This will be added before the content..</p> ' ;
      $add_sur_content =  '<p> This will be added after the content..</p> ' ;
      $content = $add_pre_content  . $original_content  . $add_sur_content ;

      // Returns the content.
      return $content;
  }

add_filter('the_content', 'add_content_filter');

由于某些原因,即使激活了插件,插件也不会修改其内容。我使用了以下代码:

wordpress插件如何添加内容?

作为参考。为了使代码正常工作,我还需要做其他事情吗?

Miquel Correa卡萨布兰卡

已解决,可能是由于托管插件中未更新的代码更改所致。它应该像这里写的那样工作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

了解wordpress the_content

覆盖 Wordpress 插件钩子

WordPress apply_filters( 'the_content', 'func_name' ) 在另一个钩子中不起作用

WordPress:front-page.php上的the_content过滤器

WordPress的the_content(); 显示内容和附件

wordpress-如果bbpress显示the_content()

WordPress:get_the_content()和the_content()之间的区别

如何在 WordPress 中使用 upgrader_process_complete 钩子来检查特定的插件更新

有条件的“ the_content”过滤器wordpress

wordpress the_content()未在正确的div中显示

需要从the_content()获取所有<img>;在WordPress中?

从 WordPress 中的“the_content”功能中剪切文本

在 WordPress 中 the_content() 前后添加内联图标

Wordpress the_content()输出文档类型声明

从 the_content WordPress 中删除带有 ID 的 div

如何在WordPress中分离帖子的the_content

WordPress 将 php 代码运行到 the_content 循环中

在Wordpress上使用插件显示内容来代替后内容

如何使用 WordPress 插件上的构造函数覆盖类?

如何使用the_content过滤器解决问题

在 wordpress 上安装 Mautic 插件

在Wordpress中使用钩子添加菜单

通过ID获取the_content并在WordPress中保留<p> -tag

使用插件 Restrict Content Pro 限制對 WordPress 中評論的訪問

在wordpress插件中使用Jquery

the_content()在div外部显示

在prestashop 1.4上使用钩子updateQuantity

更新后的Wordpress自定义钩子以获取插件版本(最新)

无法在联系表单插件(Wordpress)上使用jQuery禁用提交按钮