如何将Jetpack中包含的sharedaddy按钮移动到帖子或页面内容之前,而不是之后?我看到了sharing-service.php
打印按钮的功能与内容过滤器挂钩:add_filter( \'the_content\', \'sharing_display\', 19 );
我不确定在我的功能中放置什么。php文件来覆盖它。我想我需要以某种方式sharing-service.php
预先添加到the_content
而不是附加到它。
如何将Jetpack中包含的sharedaddy按钮移动到帖子或页面内容之前,而不是之后?我看到了sharing-service.php
打印按钮的功能与内容过滤器挂钩:add_filter( \'the_content\', \'sharing_display\', 19 );
我不确定在我的功能中放置什么。php文件来覆盖它。我想我需要以某种方式sharing-service.php
预先添加到the_content
而不是附加到它。
基本上是共享服务中的it线480。PHP上面写着:
return $text.$sharing_content;
应该是这样的return $sharing_content.$text;
现在更改该文件不会使您的更改保持更新状态,因此您可以将该函数(sharing\\u display)复制到您的函数中。php并将其重命名为其他名称,比如my_sharing_display
然后在那里进行更改。接下来,您需要删除插件添加的过滤器,并在函数中替换为您自己的so。php添加:
//remove old
remove_filter( \'the_content\', \'sharing_display\');
remove_filter( \'the_excerpt\', \'sharing_display\');
//add new
add_filter( \'the_content\', \'my_sharing_display\', 19 );
add_filter( \'the_excerpt\', \'my_sharing_display\', 19 );
更新remove\\u过滤器挂钩实际上没有删除,因为它缺少codex中的优先级参数:重要提示:要删除挂钩,添加挂钩时,$function\\u To\\u remove和$priority参数必须匹配。这适用于过滤器和操作。移除失败时不会发出警告。
so更改:
remove_filter( \'the_content\', \'sharing_display\');
remove_filter( \'the_excerpt\', \'sharing_display\');
收件人:remove_filter( \'the_content\', \'sharing_display\',19);
remove_filter( \'the_excerpt\', \'sharing_display\',19);
尝试以下操作:
<?php
if ( function_exists( \'sharing_display\' ) ) {
echo sharing_display();
}
the_content();
?>
为我工作另一种选择是直接编辑Jetpack插件文件。将两者都取出add_filters()
对于the_content
和the_excerpt
来自共享服务。php。
然后你可以手动把<?php echo sharing_display(); ?>
在主题的循环中,无论您希望共享栏位于何处。
我是updating the codex page example for action hooks, 在游戏中完成一些可重用的功能(最初是针对这里的一些Q@WA)。但后来我遇到了一个以前没有意识到的问题:在挂接到一个函数以修改变量的输出后,我再也无法决定是要回显输出还是只返回它。The Problem: 我可以修改传递给do_action 用回调函数钩住。使用变量修改/添加的所有内容仅在回调函数中可用,但在do_action 在原始函数内部调用。很高兴:我将其修改为一个工作示例,因此您可以将其复制/粘贴