Чтобы преобразовать JSON-LD в WordLift в асинхронный режим, вы можете добавить в файл functions.php темы следующее:
// Disable the asynchronous JSON-LD.
add_filter( 'wl_jsonld_enabled', function () {
return false;
} , 10, 0 );
// Hook to the `wp_head` to output the JSON-LD.
add_action( 'wp_head', function () {
// Check that the Wordlift_Jsonld_Service exists.
if ( ! class_exists( 'Wordlift_Jsonld_Service' ) ) {
echo '<!-- WordLift JSON-LD service not found. -->';
return;
}
// Determine whether this is the home page or whether we're displaying a single post.
$is_homepage = is_home() || is_front_page();
$post_id = is_singular() ? get_the_ID() : null;
// Get the JSON-LD.
$jsonld = json_encode( Wordlift_Jsonld_Service::get_instance()
->get_jsonld( $is_homepage, $post_id ) );
// Finally print the JSON-LD out.
?>
<script type="application/ld+json"><?php echo $jsonld; ?></script>
<?php
}, 10, 0 );