• I am ordering posts with a custom date, but it wont display two posts with the same custom date and display in date order. I really need help with this please. Below is the code that is ordering the date:

    <?php ; }  elseif  ( is_page( 'Older People' ) || '186' == $post->post_parent ) {	?>
    
    <?php
    $agenda = get_posts('&category_name=older-people&numberposts=-1&order=DESC'); ?>
    	<?php
    // an empty array
    $date_order = '';
    if( $agenda ) : ?> <?php  foreach( $agenda as $post ) : setup_postdata( $post ); ?> 
    
    <?php 	$custom_date = get_post_custom_values('fund_dead');
    	if (isset($custom_date[0])) {
    	$evento = strtotime($custom_date[0]);
    	} else {
       $evento = strtotime($post->post_date_gmt);
    			}
    	$date_order[$evento] = $post->ID;
    
    // now the array contain key as date and post ID as value
    	 ?>
    
    	<?php endforeach;  ?>
     	<?php endif; ?>
    
    <? // and the second
    
    // order the date in the custom field
    ksort($date_order);
    
    foreach ($date_order as $key => $val) {
     query_posts('p='.$val);
    global $more;
    $more = 0; 
    
    // the second Loop
    while (have_posts()) : the_post(); ?>
    
    <div class="divide"></div>
    
    <div class="event-main">
    
    <a href="<?php the_permalink() ?>"><h1><?php the_title(); ?></h1></a>
    
    <?php
       $eventDate = get_post_meta($post->ID, 'fund_dead', true);
       $today     = esc_html_e( date( '' , strtotime( $fund_dead ) ) );
       if($eventDate == $today) { ?>
    
         <h3>Deadline: <span id="event-list"><?php $date = 'Ongoing' ; echo($date); ?></span> </h3>
    
      <?php } else { ?>
    
          <h3>Deadline: <span id="event-list"><?php $fund_dead = get_post_meta($post->ID, 'fund_dead', true);
    esc_html_e( date_i18n( 'l, F jS, Y' , time( $fund_dead ) ) ); ?></span> </h3>
    
      <?php } ?>
    
    <h3>Eligibility: <span id="event-list"><?php $fund_elig = get_post_meta($post->ID, 'fund_elig', true);
    echo apply_filters('',  $fund_elig); ?></span> </h3>
    
    <a class="event-more" href="<?php the_permalink() ?>">Read More</a>
    
    </div>
    <div style="clear:both;"></div>  <?php endwhile; ?>
    
     <?php	} ?>

    You can view the site here: (https://www.fundingforall.org.uk/funding/older-people/)

    [No bumping. If it’s that urgent, consider hiring someone.]

  • The topic ‘Wont show two posts with same custom date’ is closed to new replies.