Title: thorbj's Replies | WordPress.org

---

# thorbj

  [  ](https://wordpress.org/support/users/thorbj/)

 *   [Profile](https://wordpress.org/support/users/thorbj/)
 *   [Topics Started](https://wordpress.org/support/users/thorbj/topics/)
 *   [Replies Created](https://wordpress.org/support/users/thorbj/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/thorbj/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/thorbj/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/thorbj/engagements/)
 *   [Favorites](https://wordpress.org/support/users/thorbj/favorites/)

 Search replies:

## Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)

 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [Translation](https://wordpress.org/support/topic/translation-191/)
 *  Thread Starter [thorbj](https://wordpress.org/support/users/thorbj/)
 * (@thorbj)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/translation-191/#post-4848108)
 * Great, the files are sent.
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Change order of posts and exclude some posts](https://wordpress.org/support/topic/change-order-of-posts-and-exclude-some-posts/)
 *  Thread Starter [thorbj](https://wordpress.org/support/users/thorbj/)
 * (@thorbj)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/change-order-of-posts-and-exclude-some-posts/#post-2135654)
 * Ok, thanks! I think I got it now 🙂
    I ended up with this code:
 *     ```
       <?php if(have_posts()) : ?>
       <?php $loop = new WP_Query( array(
       'posts_per_page' => 10,
       'cat'      => 15,
       'meta_key' => 'Dato',
       'orderby' => 'STR_TO_DATE(meta_value, \'%d/%m/%Y\')',
       'order' => 'ASC') );
       while ( $loop->have_posts() ) : $loop->the_post();
       ```
   
 * Also I added the following, to exclude expired posts:
 *     ```
       $expirationtime = get_post_custom_values('expiration');
       	if (is_array($expirationtime)) {
       	$expirestring = implode($expirationtime);
       	}
   
       $secondsbetween = strtotime($expirestring)-time();
       if ( $secondsbetween > 0 ) {
       ```
   
 * I had to add another custom field called `expiration`, populated with `mm/dd/
   yyyy 00:00:00`, for this to work.
 * Again, thanks alot 🙂
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Change order of posts and exclude some posts](https://wordpress.org/support/topic/change-order-of-posts-and-exclude-some-posts/)
 *  Thread Starter [thorbj](https://wordpress.org/support/users/thorbj/)
 * (@thorbj)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/change-order-of-posts-and-exclude-some-posts/#post-2135649)
 * Thanks again 🙂
    But I still can’t figure this out. Now, when I replace `<?php
   if (have_posts()) : while (have_posts()) : the_post(); ?>` with your code, it
   only returns a blank page. It looks as it can’t find any posts to display. What
   am I doing wrong here?
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Change order of posts and exclude some posts](https://wordpress.org/support/topic/change-order-of-posts-and-exclude-some-posts/)
 *  Thread Starter [thorbj](https://wordpress.org/support/users/thorbj/)
 * (@thorbj)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/change-order-of-posts-and-exclude-some-posts/#post-2135647)
 * Thanks for the response.
    How do I use this in my query? When I replace `<?php
   query_posts('category_name=events'); ?>` on line 29 with `<?php query_posts('
   meta_key=Dato&orderby=meta_value'); ?>`, i break the code.
 * Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)