Support

Account

Forum Replies Created

  • John, thank you for all your help.

    Unfortunately, all this is too difficult for me.

    Thank you once again ๐Ÿ™‚

  • Thank you for your commitment.

    Yes, I am using a pre_get_posts filter (functions.php) and archive-event.php (with standard loop to display posts).

    I understand that performance is very important, but I cannot display the pages separately because I am using the FacetWP plugin.

    And now I don’t know what to do anymore ๐Ÿ™

  • Thank you. I know more now.

    But I don’t know where to add it.
    To the main query (archive-event.php) or in the pre_get_posts filter?

  • John, thank you for the tips, but I think my knowledge is too little. Is it more or less like this?

    $now = date('Y-m-d H:i:s');
    
    	$meta_query = array(
    
    		'meta_query'   => array(
    
    			'relation'      => 'OR',
    
    				array(
    					'event_start' => array(
    						'key'       => 'start_date',
    						'compare'   => '<',
    						'value'     => $now,
    						'type'      => 'DATETIME'
    					),
    					'event_end'   => array(
    						'key'       => 'end_date',
    						'compare'   => '>',
    						'value'     => $now,
    						'type'      => 'DATETIME'
    					),
    				),
    
    				array(
    					'event_upcoming' => array(
    						'key'       => 'start_date',
    						'compare'   => '>=',
    						'value'     => $now,
    						'type'      => 'DATETIME'
    					)
    				),
    
    				array(
    					'event_past' => array(
    						'key'       => 'end_date',
    						'compare'   => '<',
    						'value'     => $now,
    						'type'      => 'DATETIME'
    					),
    				),
    			),
    		);
    
    		$query->set('meta_query', $meta_query);
    
    		$query->set(
    			'orderby',
    			array(
    				'event_start' => 'DESC',
    				'event_end' => 'DESC',
    				'event_upcoming' => 'DESC',
    				'event_past' => 'ASC',
    			)
    		);
    
    		$query->set('order', 'ASC');

    I have no ideas anymore and I am broken ๐Ÿ™

  • Thank you very much for your answer.
    Eventually I’m done with the code below:

    $now = date('Y-m-d H:i:s');
    
            $meta_query = array(
    
                'meta_query'   => array(
    
                    'relation' => 'OR',
    
                    array(
                        'event_start' => array(
                            'key'     => 'start_date',
                            'compare' => '<',
                            'value'   => $now,
                            'type'    => 'DATETIME'
                        ),
    
                        'event_end'   => array(
                            'key'     => 'end_date',
                            'compare' => '>',
                            'value'   => $now,
                            'type'    => 'DATETIME'
                        ),
                    ),
    
                    array(
                       'event_upcoming' => array(
                            'key'       => 'start_date',
                            'compare'   => '>=',
                            'value'     => $now,
                            'type'      => 'DATETIME'
                        )
                    ),
    
                    array(
    
                        'event_past'  => array(
                            'key'     => 'end_date',
                            'compare' => '<',
                            'value'   => $now,
                            'type'    => 'DATETIME',
                        ),
                    ),
    
                ),
    
            );
            $query->set('meta_query', $meta_query);
    
            $query->set(
                'orderby',
                array(
                    'event_start' => 'DESC',
                    'event_end' => 'DESC',
                    'event_upcoming' => 'ASC',
                    'event_past' => 'DESC',
                )
            );
    
    $query->set('order', 'DESC');

    And I was able to get that order:
    1. ONGOING EVENTS
    2. PAST EVENTS
    3. UPCOMMING EVENTS

    Is it not possible to use WP_Query for PAST EVENTS to be last?

    Are there any other ways?

  • Any plans on implementing it in a later release? Anyone know something? This feature would be great!

  • Hi Elliot

    It doesn’t work (ACF 5.3.9.2, WP 4.5.3). Anything has changed?

  • Hi, Iโ€™m having the same problemโ€ฆ

    Any update? Did someone find a solution?

    Thank you.

  • Great solution!

    Thank you Elliot.

  • I have exactly the same problem.

  • I have the same problem.

  • Ok, I understand.

    enorog, thank you for your support.

  • Thakns.

    Updated code here:

    <?php setlocale(LC_ALL, array('en_US.UTF8','en_US','english')); ?>
    
    <?php query_posts( array( 'post_type' => 'custom_post_name', 'post_status' => 'publish', 'posts_per_page' => 1 ) ); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<?php if(have_rows('repeater_field_name')): ?>
    	<?php while( have_rows('repeater_field_name') ): the_row(); ?>
                
    						<?php
    						$dateformatstring = "%A %d %B, %Y";
    						$unixtimestamp = strtotime(get_sub_field('date_picker'));
    						echo strftime($dateformatstring, $unixtimestamp);
    						?>            
                     
                
    
    	<?php endwhile; ?>
    	<?php endif; ?>
    
    <?php endwhile; endif; ?>

    But it shows me everywhere “Thursday 01 January, 1970 “, instead of getting from the ACF Date Picker Fields.

  • This is my final code, but it also does not work:

    <?php setlocale(LC_ALL, array('en_US.UTF8','en_US','english')); ?>
    
    <?php query_posts( array( 'post_type' => 'custom_post_name', 'post_status' => 'publish', 'posts_per_page' => 1 ) ); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<?php if(have_rows('repeater_field_name')): ?>
    	<?php while( have_rows('repeater_field_name') ): the_row(); ?>
    
    			// ORIGINAL <?php the_sub_field('date_picker'); ?>
                
    						<?php
    						$dateformatstring = "M";
    						$unixtimestamp = strtotime(get_sub_field('date_picker'));
    						echo date_i18n($dateformatstring, $unixtimestamp);
    						?>            
                     
                
    
    	<?php endwhile; ?>
    	<?php endif; ?>
    
    <?php endwhile; endif; ?>
  • I see the name of the month in french, and I would in english ๐Ÿ™

  • I don’t know what I’m doing wrong, but it still doesn’t work. Below my original code:

    <?php query_posts( array( 'post_type' => 'custom_post_name', 'post_status' => 'publish', 'posts_per_page' => 1 ) ); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<?php if(have_rows('repeater_field_name')): ?>
    	<?php while( have_rows('repeater_field_name') ): the_row(); ?>
    
    			<?php the_sub_field('date_picker'); ?>
    
    	<?php endwhile; ?>
    	<?php endif; ?>
    
    <?php endwhile; endif; ?>
  • Thank you, but it doesn’t work.

  • Thanks,

    How to implement it using the ACF?
    `<?php the_sub_field(‘data_picker’); ?>

    I’m sorry, but it’s a little bit too difficult for me…

  • Thanks for the reply, but I didn’t mean the date format. I mean the language, that is, instead of “Juin” (in french), “June” (in english). Is it possible?

Viewing 21 posts - 1 through 21 (of 21 total)