WordPress.org

Support

Support » Plugins and Hacks » Miniposts » Sorting miniposts by date

Sorting miniposts by date

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sorting miniposts by date’ is closed to new replies.
Skip to toolbar