0
I need to change the order of items in a listing. Which is decreasing and need to change to increasing.
It’s a code not made by me, but I need to maintain.
<div class="wrapper wrapper-noticia-listagem cf" data-rel-evento="noticias" <?php if($noticias_tag) { echo 'style="display: block;"'; } ?> >
<?php
foreach($noticias_tag as $noticia_tag) {
if(trim($noticia_tag['link_direto']) === "" or $noticia_tag['link_direto'] === null) {
$categoria_slug = $noticia_tag['categoria_slug'];
$noticia_slug = $noticia_tag['slug'];
$noticia_id = $noticia_tag['id'];
$link = "/noticias/$categoria_slug/$noticia_slug-$noticia_id";
$target = "";
} else {
$target = "target='_blank'";
$link = $noticia_tag['link_direto'];
}
?>
<p>
<strong>
<a href="<?php echo $link; ?>" <?php echo $target; ?>>
<?php echo $noticia_tag['titulo']; ?>
</a>
</strong><br>
<?php echo $noticia_tag['chamada']; ?>
<br> Enviada em
<?php echo datetimetostrd($noticia_tag['data_publicacao']); ?> - <a href="<?php echo $link; ?>" <?php echo $target; ?>>Leia mais</a>
</p>
<?php } ?>
</div>
From what I understand, I need to create a variable that will take all the div which contains the news listing on p and ali order via PHP.
You can use the function
usort
passing the function that compares elements of the type of the list you have– Isac
What is the field by which you want to sort? Title, date of publication, author?
– C. Bohok
Maybe making this query sql change would solve your problem easier
– Otto