【发布时间】:2018-10-22 09:09:19
【问题描述】:
我想将 JSON-LD 中 WordLift 插件导出的 @type: Article 更改为 @type: NewsArticle。
我该怎么做?
【问题讨论】:
标签: wordpress json-ld wordlift
我想将 JSON-LD 中 WordLift 插件导出的 @type: Article 更改为 @type: NewsArticle。
我该怎么做?
【问题讨论】:
标签: wordpress json-ld wordlift
您可以在将 JSON-LD 输出发送到客户端之前对其进行过滤并更改它的任何部分,例如在这种特定情况下:
add_filter( 'wl_post_jsonld', function( $jsonld ) {
// Bail out if `@type` isn't set or isn't `Article`.
if ( ! isset( $jsonld['@type'] ) || 'Article' !== $jsonld['@type'] ) {
return $jsonld;
}
$jsonld['@type'] = 'NewsArticle';
return $jsonld;
} );
【讨论】: