Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to display "articles" by date of publication ? WordPress

Hello,

I have a page where articles are display. But it didn't show the last published one at first position.
I want all my articles to be display in the page and to be shown by date of publication, last publish first and older ones after.

Please find here the code use to display the article in the page :

<?php

$category_description = category_description();

if ( ! empty( $category_description ) )

echo '<div class="archive-meta">' . $category_description . '</div>';

get_template_part( 'loop', 'category' );

?>




I may use something like "order=ASC" ...

Thanks for the help.

Answers (2)

2016-05-03

Arnav Joy answers:

can you show us full code?

and also code for loop-category.php ?


guillaume guillaume comments:

Hello Arnav, long time ...

Please find here the code of the page :

<?php
/*
Template Name: Agenda Londres
*/
?>


<?php get_header(); ?>

<div id="container">
<div id="content" role="main">
<div class="link"><img src="http://www.headlinesphotos.com/wp-content/uploads/link3.png" alt="link" width="31" height="15" class="alignnone size-full wp-image-1624" /><a href="http://www.eventail.be" target="_new">www.eventail.be</a></div>

<div class="about"><ul>
<?php wp_list_categories('title_li=&order=ASC&include=74,81,93,80,102,106,104,60,73,62,86,91,63,72,97,98,107,108,109,110,111,87,76,92,100,82,84,75,65,66,71,103,68,59,95,78,99,83,69,47,90,79,70,89,101,85,115,117,'); ?>
</ul></div>
</div><!-- #content -->
</div><!-- #container -->


I don't have a page called "loop-category.php" only these pages :

loop-attachment.php
loop-page.php
loop-single.php
loop.php


guillaume guillaume comments:

ERRATUM

Here is the code of the page :



<?php get_header(); ?>


<div id="container">
<div id="content" role="main">


<?php
$category_description = category_description();
if ( ! empty( $category_description ) )
echo '<div class="archive-meta">' . $category_description . '</div>';

get_template_part( 'loop', 'category' );
?>

<div class="galerie_londres"><ul>
<?php wp_list_categories('title_li=&order=ASC&include=74,81,93,80,102,106,104,60,73,62,86,91,63,72,97,98,107,108,109,110,111,87,76,92,100,82,84,75,65,66,71,103,68,59,95,78,99,83,69,47,90,79,70,89,101,85,117,'); ?>
</ul>
</div>



</div><!-- #content -->







</div><!-- #container -->

<?php get_footer(); ?>


Arnav Joy comments:

please show me loop.php


guillaume guillaume comments:

Here is loop.php



<?php if ( ! have_posts() ) : ?>
<div id="post-0" class="post error404 not-found">
<h1 class="entry-title"><?php _e( 'Not Found', 'imbalance2' ); ?></h1>
<div class="entry-content">
<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'imbalance2' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</div><!-- #post-0 -->
<?php endif; ?>

<?php $imbalance2_theme_options = get_option('imbalance2_theme_options') ?>

<div id="boxes">
<?php while ( have_posts() ) : the_post(); ?>

<div class="box">
<div class="rel">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('homepage-thumb', array('alt' => '', 'title' => '')) ?></a>
<?php if ($imbalance2_theme_options['images_only'] == 0): ?>
<div class="categories"><?php imbalance2_posted_in(); ?></div>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php the_excerpt() ?>
<div class="posted"><?php imbalance2_posted_on() ?> <span class="main_separator">/</span>
<?php echo comments_popup_link( __( 'No comments', 'imbalance2' ), __( 'One Comment', 'imbalance2' ), __( '% Comments', 'imbalance2' ) ); ?>
</div>
<?php endif ?>
<div class="texts">
<?php if ($imbalance2_theme_options['images_only'] == 1): ?>
<a class="transparent" href="<?php the_permalink(); ?>"><?php the_post_thumbnail('homepage-thumb', array('alt' => '', 'title' => '')) ?></a>
<?php endif ?>
<div class="abs">
<?php if ($imbalance2_theme_options['images_only'] == 0): ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('homepage-thumb', array('alt' => '', 'title' => '')) ?></a>
<?php endif ?>
<div class="categories"><?php imbalance2_posted_in(); ?></div>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php the_excerpt() ?>
<div class="posted"><?php imbalance2_posted_on() ?> <span class="main_separator">/</span>
<?php echo comments_popup_link( __( 'No comments', 'imbalance2' ), __( 'One Comment', 'imbalance2' ), __( '% Comments', 'imbalance2' ) ); ?>
</div>
</div>
</div>
</div>
</div>

<?php endwhile; ?>
</div>

<?php if ( $wp_query->max_num_pages > 1 ) :
if ( $imbalance2_theme_options['navigation'] == 0 ) : // Default ?>

<div class="fetch">
<?php next_posts_link( __( 'Load more posts', 'imbalance2' ) ); ?>
</div>

<script type="text/javascript">
// Ajax-fetching "Load more posts"
$('.fetch a').live('click', function(e) {
e.preventDefault();
$(this).addClass('loading').text('Loading...');
$.ajax({
type: "GET",
url: $(this).attr('href') + '#boxes',
dataType: "html",
success: function(out) {
result = $(out).find('#boxes .box');
nextlink = $(out).find('.fetch a').attr('href');
$('#boxes').append(result).masonry('appended', result);
$('.fetch a').removeClass('loading').text('Load more posts');
if (nextlink != undefined) {
$('.fetch a').attr('href', nextlink);
} else {
$('.fetch').remove();
}
}
});
});
</script>

<?php elseif ( $imbalance2_theme_options['navigation'] == 1 ) : // Infinite scroll ?>

<div class="infinitescroll">
<?php next_posts_link( __( 'Load more posts', 'imbalance2' ) ); ?>
</div>

<script type="text/javascript">
// Infinite Scroll
var href = 'first';
$(document).ready(function() {
$('#boxes').infinitescroll({
navSelector : '.infinitescroll',
nextSelector : '.infinitescroll a',
itemSelector : '#boxes .box',
loadingImg : '<?php echo get_bloginfo('stylesheet_directory') ?>/images/loading.gif',
loadingText : 'Loading...',
donetext : 'No more pages to load.',
debug : false
}, function(arrayOfNewElems) {
$('#boxes').masonry('appended', $(arrayOfNewElems));
if (href != $('.infinitescroll a').attr('href'))
{
href = $('.infinitescroll a').attr('href');
}
});
});
</script>

<?php endif; ?>

<?php endif; ?>

2016-05-03

Hariprasad Vijayan answers:

Hello,

Are you trying to show default WordPress posts in a custom page?

Can you share URL of page?
Regards,
Hariprasad