所以我得到了这个密码
add_filter( 'abcdefg/json_ld', function( $data, $jsonld ) {
if ( is_single() ) {
$data['richSnippet']['articleBody'] = $jsonld->post->post_content;
}
return $data;
}, 11, 2);
我只是简单地尝试使用post_content,基本上只提供文本,目前它添加了WPbakery标记(E.G,等等,还有通常的h1/2/3等等)
我可以读一些PHP代码,但没有接近编写代码的水平。我试图在返回后获取$data,并通过wp_strip_tags“处理”它,然后我想我可能应该在它返回之前运行$data。那不起作用。
所以我来了..。有小费吗?谢谢!
另外,为了确保它在functions.php上运行。
发布于 2019-07-30 23:24:05
这些不是HTML标签,而是短代码。wp_strip_all_tags
将去掉
或等HTML标记。对于短代码,您应该去掉这些短代码。
我做了一个快速的google,在官方开发文档上找到了strip_shortcodes
:
https://developer.wordpress.org/reference/functions/strip_简编/
https://wordpress.stackexchange.com/questions/344019
复制相似问题