Home Forums General Issues Permalink call from Date Time Picker code


Permalink call from Date Time Picker code

  • I was reading this page

    I used some code from there. It all works except I can’t get the permalink to work.

    I usually use the_permalink() but that doesn’t work. I tried echo get_permalink();


    Nothing works. Can you tell me what call should I use to get the link for the blog post?


    // find date time now
    $date_now = date(‘Y-m-d H:i:s’);
    $time_now = strtotime($date_now);

    // find date time in 7 days
    $time_next_week = strtotime(‘+90 day’, $time_now);
    $date_next_week = date(‘Y-m-d H:i:s’, $time_next_week);

    // query events
    $posts = get_posts(array(
    ‘posts_per_page’ => -1,
    ‘post_type’ => ‘post’,
    ‘cat’ => ‘events’,
    ‘meta_query’ => array(
    ‘key’ => ‘event_date’,
    ‘compare’ => ‘BETWEEN’,
    ‘value’ => array( $date_now, $date_next_week ),
    ‘type’ => ‘DATETIME’
    ‘order’ => ‘ASC’,
    ‘orderby’ => ‘meta_value’,
    ‘meta_key’ => ‘event_date’,
    ‘meta_type’ => ‘DATETIME’

    if( $posts ): ?>

    <?php foreach( $posts as $p ): ?>
    <div class=”event”>
    <div class=”eventlocation”>
    <h3>“><?php echo $p->post_title; ?></h3>
    <div class=”eventlocation”><?php the_field(‘event_location’, $p->ID); ?></div>
    <div class=”eventdate”> <?php the_field(‘event_date’, $p->ID); ?> | <?php the_field(‘event_time’, $p->ID); ?> – <?php the_field(‘event_end_time’, $p->ID); ?>
    <?php endforeach; ?>
    <?php endif; ?>

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.