Hi
Does anyone know if its possible to sort Miniposts by publication date, showing the oldest post first?
Many thanks.
Hi
Does anyone know if its possible to sort Miniposts by publication date, showing the oldest post first?
Many thanks.
Didn't test this but:
<?php
$args=array(
'meta_key' => '_mini_post',
'order' => 'ASC',
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo 'List of mini posts';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>Hi - thank you so much for that. I'm afraid my php is a bit limited. I tried adding it but created a fatal error. Is there a particular place in the code it needs to go in? I couldn't see anything about a sort order but I may well have missed it.
The 'order' clause does the sorting.
Consider downloading and installing Otto's PHP Code Widget, then put that code in one of those widgets.
This topic has been closed to new replies.