WordPress Snippet Code
-
<?php
$months = [
'Jan' => 'JAN',
'Feb' => 'FEV',
'Mar' => 'MAR',
'Apr' => 'ABR',
'May' => 'MAI',
'Jun' => 'JUN',
'Jul' => 'JUL',
'Aug' => 'AGO',
'Sep' => 'SET',
'Oct' => 'OUT',
'Nov' => 'NOV',
'Dec' => 'DEZ',
];
$meuArray = api_endpoint('chsa_api_test', 'GetTorneios', array('debug' => false));
if (empty($meuArray)) {
echo "O array está vazio.";
} else {
$painel = array_slice($meuArray, 0, 6);
echo "<div class=\"container\">";
foreach ($painel as $posicao => $elemento) {
echo "<div class=\"col-md-6 mx-auto\">";
echo "<a href='https://wordpress?ID=" . $elemento['ID'] . "'>";
echo "<div class=\"event card\">";
echo "<div class=\"datas\">";
// Exibir data de início e data de término
$dataObjInicio = new DateTime($elemento['DATA_INICIO']);
$diaInicio = $dataObjInicio->format('d');
$mesInicio = $months[strftime('%b', strtotime($elemento['DATA_INICIO']))];
$dataObjFim = new DateTime($elemento['DATA_FIM']);
$diaFim = $dataObjFim->format('d');
$mesFim = $months[strftime('%b', strtotime($elemento['DATA_FIM']))];
if ( ($diaInicio == $diaFim ) && ($mesInicio == $mesFim) ) {
echo "<div class=\"data-inicio\">" . $diaInicio . "<br><span>" . $mesInicio . "</span></div>";
}
else {
echo "<div class=\"data-inicio\">" . $diaInicio . "<br><span>" . $mesInicio . "</span></div>";
echo "<div class=\"data-separator\">a</div>";
echo "<div class=\"data-fim\">" . $diaFim . "<br><span>" . $mesFim . "</span></div>";
}
echo "</div>";
echo "<div class=\"descricao\">" . $elemento['DESCRICAO'] . "</div>";
echo "<span class='meu-botao'>+</span>";
echo "</div>";
echo "</div>";
echo "</a>";
}
echo "</div>";
}
?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘WordPress Snippet Code’ is closed to new replies.