Listing events not showing when date is today.

Joined
Mar 25, 2021
Messages
28
Reaction score
0
Hi, I have some old PHP code I am trying to sort through and it is for pulling 3 upcoming events and I guess it was written so todays event doesn't show and am trying to fix that. I was wondering if anyone can make sense of this?

PHP:
                <ul>
                  <?php  $urlSplits = explode('/', $_SERVER['REQUEST_URI']); ?>
                  <?php
                    if ($urlSplits[3] != '') {
                      $currentYear = $urlSplits[3];
                    } else {
                      $currentYear = date('Y');
                    }
                  ?>
                  <?php  query_posts('cat=3&order=DESC');?>
                  <?php  if (have_posts()) : ?>

                    <?php  while (have_posts()) : the_post(); ?>
                      <?php
                        $eventDate = get_field('start-date', $post->ID);
                        $eventDate = str_replace(', ', ' ', $eventDate);
                        $eventDate = strtotime($eventDate);
                        $eventDateArray[] = $eventDate;
                        $eventPIDArray[] = $post->ID;
                      ?>
                    <?php  endwhile; ?>
                    <?php
                      asort($eventDateArray);
                      $todayDate = date('F-j-Y');
                      $todayDate = strtotime($todayDate);
                    ?>
                    <?php  foreach ($eventDateArray as $k => $v) { ?>
                      <?php  if ($eventDateArray[$k] >= ($todayDate - 100000)) { ?>
                        <?php  $temp = $todayDate - $eventDateArray[$k]; ?>
                        <?php  if ($temp <= 1000000) { ?>
                          <?php  $sortedDateArray[] = $temp; ?>
                          <?php  $sortedPID[] = $eventPIDArray[$k]; ?>
                        <?php  } ?>
                      <?php  } ?>
                    <?php  } ?>
                    <?php  $showPostsCount = 0;?>
                    <?php  if (count($sortedDateArray) > 0) { ?>
                      <?php  foreach($sortedDateArray as $k => $v) { ?>
                        <?php  if ($showPostsCount < 3) { ?>
                          <li>
                            <em><?php  the_field('start-date', $sortedPID[$k]); ?></em>
                            <strong><a href="<?php  echo get_permalink($sortedPID[$k]); ?>" rel="bookmark"><?php  echo get_the_title($sortedPID[$k]); ?></a></strong>
                          </li>
                          <?php  $showPostsCount++; ?>
                        <?php  } ?>
                      <?php  } ?>
                    <?php  } else { ?>
                    <li>
                      <em>No Events Scheduled</em>
                      <strong><?php  _e("Check back soon for upcoming events."); ?></strong>
                    </li>
                    <?php  } ?>
                <?php  else : ?>
                    <li>
                      <em>No Events Scheduled</em>
                      <strong><?php  _e("Check back soon for upcoming events."); ?></strong>
                    </li>
                <?php  endif; ?>
                </ul>

I was thinking it has to do with the following lines in the script above but not entirely sure?

PHP:
<?php  if ($eventDateArray[$k] >= ($todayDate - 100000)) { ?>
                        <?php  $temp = $todayDate - $eventDateArray[$k]; ?>
                        <?php  if ($temp <= 1000000) { ?>

Would appreciate some help with this if possible. Thanks!
 
Joined
Mar 11, 2022
Messages
227
Reaction score
32
A. Okay. So i can't help you. I hate WP and all the other Open Source Crab. Maybe someone else can help you
 
Joined
Mar 25, 2021
Messages
28
Reaction score
0
ended up changing ended up changing
Code:
$todayDate - 100000
to
Code:
$todayDate - 200000
since that was basically 1 day in seconds (86400?) I made it 2 days.

So I changed a 1 to a 2. Didn’t end up having much to do with WP after all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,661
Latest member
NadineBour

Latest Threads

Top