Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7550045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:06:46+00:00 2026-05-30T10:06:46+00:00

Sorry for a probably dim question but I can’t find the correct terminology to

  • 0

Sorry for a probably dim question but I can’t find the correct terminology to find the solution.

I’ve got a wordpress loop [a php while loop] for my post_type event. Each post has a value with a date string. I am comparing this string with the current date. The date values start in the future and end a few years ago.

When the loop gets to posts with date values lower than the current date [$date > $eventdate] I want to insert some code [a divider <article>] and then continue my loop. How do I do this?

Seems very simple but please help as I’m stuck!

EDIT: I tried to nest two conditional while loops with the divider code in between but that was very bad. Then tried something similar with if’s but I got that wrong too. Here’s the [simplified] code to work with:

    <?php
    $date = date(Ymj);
      if ( have_posts() ) : while ( have_posts() ) : the_post();
        $eventdate = get_post_meta($post->ID, 'event-date', true); ?>
    <article>post goes here</article>
      <?php endwhile; else: 
    ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:06:47+00:00Added an answer on May 30, 2026 at 10:06 am
    <?php
    $did_article = false;
    $now = time();
    if ( have_posts() ) : while ( have_posts() ) : the_post();
        $eventdate = get_post_meta( $post->ID, 'event-date', true );
        $eventdate = strtotime( $eventdate );
        if ( !$did_article ) {
            if ( $now > $eventdate ) {
                $did_article = true;
                // Do special article stuff here
            }
        } ?>
        Do regular post suff here
    <?php endwhile; endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is as above. Sorry, it's probably a duplicate but I couldn't find
Sorry for question but I can't find answer anywhere on internet. I couldn't find
Sorry for the probably dummy question but I'm lost. can Wi-fi network strength (dBm)
Sorry, probably another silly question, but I've got a lot of information to put
Im sorry for this probably dumm question, but I want to simply open modals
Sorry for this simple question, but I can't solve it... There is an example:
sorry for the dummy question but I cannot find a simple and clean way
sorry for the (probably) noob question, but I', new at this stuff. i have
sorry this is probably a dumb question, but I want to make the background
Sorry for the probably dumb question, but i wanted to practice loops a bit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.