2017-08-24 10 views
0

私たちのサイトでは、JSONを使用して構造化データを表示しています。フィールドの1つ(reviewBody)は、pタグ内のテキストを返します。開始タグと終了タグを削除したいと思います。JSON構造化データ記述にhtmlタグを表示

タグを取り除く手助けをするのは誰ですか?中

<script type="application/ld+json"> 
{ 
    "@context": "http://schema.org", 
    "@type": "Review", 
    "image": "<?php echo get_the_post_thumbnail_url(); ?>", 
    "reviewBody": <?=json_encode(apply_filters('the_content', $tw_entry->review_summary)); ?>, 
    "description": "<?php echo get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true); ?>", 
    "datePublished": "<?php echo get_the_date('Y-m-d'); ?>", 
    "itemReviewed": { 
     "@type": "Thing", 
     "name": "<?php the_title(); ?>" 
    }, 
    "author": { 
     "@type": "Person", 
     "name": "mr x" 
    }, 
    "reviewRating": { 
     "@type": "Rating", 
     "bestRating": "10", 
     "ratingValue": "<?php echo get_post_meta($post->ID, 'average-rating', true)/10; ?>", 
     "worstRating": "1" 
    } 
} 
</script> 

結果:

"reviewBody": <p>lorem ipsum</p> 
+0

に変更タグ?コンテンツのみ? – Noman

+0

はい、私は '

'と '

'が必要です。ですから、私は "lorem ipsum"のままにしておきます。 – DreadyE

+0

これを変更してください。<?= json_encode(apply_filters( 'the_content'、$ tw_entry-> review_summary)); ?>これを<?php echo json_encode(wp_filter_nohtml_kses($ tw_entry-> review_summary)); ?> ' – Noman

答えて

0

がHTMLを取り除くためには、あなたがそうwp_filter_nohtml_kses を使用する必要があり、この

<?=json_encode(apply_filters('the_content', $tw_entry->review_summary)); ?> 

あなたは何のHTMLを意味しない。この

<?php echo json_encode(wp_filter_nohtml_kses($tw_entry->review_summary)‌​); ?> 
関連する問題