如何从结构化数据中删除时间



我正在尝试删除事件日历(TEC(插件添加到事件中的一些结构化数据(JSON LD格式(。具体来说,我正在尝试删除开始和结束时间以下是该插件的演示网站如何出现在谷歌的结构化数据测试工具中:https://search.google.com/structured-data/testing-tool/u/0/#url=http%3A%2F%2Fwpshindig.com%2Fevents%2F

通过研究,我发现TEC有一个挂钩,它允许覆盖和调整结构化数据:https://docs.theeventscalendar.com/reference/hooks/tribe_json_ld_markup/

我还找到了一个例子,说明如何将这个钩子添加到我的主题的functions.php文件中(该网站在WordPress上运行(:

add_filter( 'tribe_json_ld_markup', 'my_func' );
function my_func( $html ) {
// Do something with $html
return $html;
}

我不太懂PHP,所以我不知道我需要用什么来替换注释,以便从结构化数据中删除时间。我希望你能帮忙!

您需要为每个操作找到一个正确的操作,在您的情况下,您只是传递相同的默认html。您可以在示例操作中修改和删除任何代码,如下所示。请记住,您需要验证这是您要采取的操作的正确操作;

add_filter( 'tribe_json_ld_markup', 'my_func' );
function my_func( $html ) {
// Do something with $html
$html = '';
return $html;
}

add_filter( 'tribe_json_ld_markup', '__return_false' );

最新更新