Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter thorbj

    (@thorbj)

    Great, the files are sent.

    Thread Starter thorbj

    (@thorbj)

    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 ??

    Thread Starter thorbj

    (@thorbj)

    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?

    Thread Starter thorbj

    (@thorbj)

    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)