poliquinp
Member
Posted 1 year ago #
Hi,
I got a problem... I'm doing a loop for my news and the date doesn't want to show up on the first element... The date still here on the other ones..
<?php
// Get lastests news
global $post;
$myposts = get_posts('numberposts=2&orderby=post_date&order=desc&category=1');
foreach($myposts as $post) {
setup_postdata($post);
?>
<h3><img src="http://www.detailformation.com/images/fleche-date.gif" align="absmiddle" /> <?php the_date('j F Y'); ?></h3>
<strong><?= the_title(); ?></strong>
<p><?= the_excerpt(); ?></p>
<p align="right" style="text-align: right">
<a href="<?= the_permalink(); ?>" title="<?= the_title(); ?>" class="plus">En savoir plus</a> <img src="http://www.detailformation.com/images/gris-fleche.gif" alt="" align="absmiddle" />
</p>
<?php } ?>
Can some one tell me why I got this problem?
Thx,
Patrice
quanxitung
Member
Posted 1 year ago #
<?php
// Get lastests news
global $post;
$args = array(
'numberposts' =>2,
'orderby' => date,
'order' => desc,
'cat' => 1
);
query_posts($args);
while(have_posts()) { the_post();
?>
<h3><img src="http://www.detailformation.com/images/fleche-date.gif" align="absmiddle" /> <?php the_time('j F Y'); ?></h3>
<?= the_title(); ?>
<p><?= the_excerpt(); ?></p>
<p align="right" style="text-align: right">
" title="<?= the_title(); ?>" class="plus">En savoir plus <img src="http://www.detailformation.com/images/gris-fleche.gif" alt="" align="absmiddle" />
</p>
<?php } ?>
poliquinp
Member
Posted 1 year ago #
@quanxitung : This is actully working pretty fine! Can you explain to me why I should use the_time() instead of the_date() in this kind of loop?
quanxitung
Member
Posted 1 year ago #
@poliquinp: working pretty fine is good. I used the_date(), i don't forget it have problem what, since i use the_time().
you can search the_date vs the_time to study.