I need to do a "if
" inside my json, but it is showing in my "if
"
"syntax error, unexpected 'if' (T_IF), expecting ',' or ';'"
Could you please help me?
<?php
$cat_video = get_the_category();
foreach($cat_video as $c){
if($c->slug=='videos'){
echo '<script type="application/ld+json">{
"@context": "https://schema.org/",
"@type": "VideoObject",
"name": "'.$titulo_replace.'",
"duration": "PT1M54S","uploadDate": "'.date("Y-m-d", strtotime($date)).'",
"thumbnailUrl": "'.$image_url.'",
"description": "'if($excerpt){.$excerpt.}else{.$titulo_replace.}'",
"contentUrl": "'.get_post_embed_url( get_the_ID() ).'",
"regionsAllowed": "pt-BR"}
</script>';
}
}
?>