Support

Account

Home Forums Search Search Results for 'event date repeater'

Search Results for 'event date repeater'

reply

  • Hey guys!

    I have the same issue, i want to display future post only.
    I tried the solution Jason typed out.

    Here is my code.

    `<?php

    //Set server timezone to central
    date_default_timezone_set(‘Europe/Amsterdam’);
    //Today’s date
    $date_1 = date(‘Ymd’, strtotime(“now”));
    //Future date – the arg will look between today’s date and this future date to see if the post fall within the 2 dates.
    $date_2 = date(‘Ymd’, strtotime(“+12 months”));

    ?>

    <?php
    //arg to determine if the post is an upcoming event.
    $upcoming_args = array(
    ‘post_type’ => ‘programma’,
    ‘posts_per_page’ => -1,
    ‘meta_key’ => ‘start_date’,
    ‘meta_compare’ => ‘BETWEEN’,
    ‘meta_type’ => ‘numeric’,
    ‘meta_value’ => array($date_1, $date_2),
    ‘orderby’ => ‘meta_value_num’,
    ‘order’ => ‘ASC’
    );
    ?>

    <?php
    // the upcoming events query
    $upcoming_query = new WP_Query( $upcoming_args );
    ?>

    <?php if ( $upcoming_query->have_posts() ) : ?>
    <!– the loop –>
    <?php while ( $upcoming_query->have_posts() ) : $upcoming_query->the_post(); ?>

    <?php the_field(‘datum’); ?>

    <?php
    if( have_rows(‘programma_tijden_2’) ): ?>
    <div id=”programma_tijden_2″>

    <?php

    // loop through rows (parent repeater)
    while( have_rows(‘programma_tijden_2’) ): the_row(); ?>
    <div class=”even-testen”>

    <!– wrap the_sub_field in elk een aparte div voor de styling –>

    <?php the_sub_field(‘tijdstip’); ?> <br />
    <?php the_sub_field(‘informatie’); ?> <br />
    <?php the_sub_field(‘extra_informatie’); ?> <br />

    </div>
    </div>

    <?php endwhile; ?>
    <?php endif;?>

    <?php endwhile; ?>

    <!– end of the loop –>

    <?php wp_reset_postdata(); ?>

    <?php else: ?>
    <p><?php _e( ‘Er zijn momenteel geen evenementen meer.’ ); ?></p>
    <?php endif; ?>
    `

    The only thing i see on my site is there are no events (the else statement)
    What am i missing?

    i’am not creating a new post, because i’am using this code. if needed i will create a new post.

    thnx in advance

  • Hi Alex,

    It would be hard to do this without saving the options page between putting in the events and then putting in contacts.

    However. You could do a check on loading of the “events” field inside contacts wether there exists some values in the Events repeater and add them as choices as a select field (for example).

    Here’s a snippet you can use as a base that should get you rolling:

    
    function my_acf_load_field( $field ){
    	
    	$events = get_field('events', 'options'); //the repeater for events
    	
    	if( $events ){
    		foreach( $events as $event ){
    			$field['choices'][$event['eventname']] = $event['eventname'] . ' (' . $event['eventdate'] . ')';
    			
    		}
    	}
    	
        return $field;
    }
    
    // acf/load_field - filter for every field
    add_filter('acf/load_field/field_key_for_events_subfield_here', 'my_acf_load_field');
    
  • Okay so I’ve tried your code, it theoretically works!

    But the query takes very long and I eventually get an error (502 bad gateaway or error 500 internal server error)

    Here is my query (it is in an array and I use that array to make the WP_Query) :

    Array
    (
        [post_status] => publish
        [post_type] => post
        [category_name] => en_cours
        [meta_query] => Array
            (
                [dept_order] => Array
                    (
                        [key] => dept_nb_for_the_order
                        [compare] => EXISTS
                    )
    
                [city_order] => Array
                    (
                        [key] => city_name_for_the_order
                        [compare] => EXISTS
                    )
    
                [arrdt_order] => Array
                    (
                        [key] => arrondissement
                        [compare] => EXISTS
                    )
    
                [repeater] => Array
                    (
                        [relation] => OR
                        [0] => Array
                            (
                                [relation] => AND
                                [surface] => Array
                                    (
                                        [key] => tous_lots_0_surface_du_lot
                                        [value] => Array
                                            (
                                                [0] => 42.5
                                                [1] => 172.5
                                            )
    
                                        [type] => numeric
                                        [compare] => BETWEEN
                                    )
    
                                [date] => Array
                                    (
                                        [key] => tous_lots_0_date_de_livraison_du_lot
                                        [value] => 20190931
                                        [compare] => >=
                                        [type] => DATE
                                    )
    
                                [selection_cheminee] => Array
                                    (
                                        [key] => tous_lots_0_etat_de_livraison
                                        [value] => "6-cheminee"
                                        [compare] => LIKE
                                    )
    
                                [non_loue] => Array
                                    (
                                        [key] => tous_lots_0_etat_de_livraison
                                        [value] => "1-loc"
                                        [compare] => LIKE
                                    )
    
                            )
    
                        [1] => Array
                            (
                                [relation] => AND
                                [surface] => Array
                                    (
                                        [key] => tous_lots_1_surface_du_lot
                                        [value] => Array
                                            (
                                                [0] => 42.5
                                                [1] => 172.5
                                            )
    
                                        [type] => numeric
                                        [compare] => BETWEEN
                                    )
    
                                [date] => Array
                                    (
                                        [key] => tous_lots_1_date_de_livraison_du_lot
                                        [value] => 20190931
                                        [compare] => >=
                                        [type] => DATE
                                    )
    
                                [selection_cheminee] => Array
                                    (
                                        [key] => tous_lots_1_etat_de_livraison
                                        [value] => "6-cheminee"
                                        [compare] => LIKE
                                    )
    
                                [non_loue] => Array
                                    (
                                        [key] => tous_lots_1_etat_de_livraison
                                        [value] => "1-loc"
                                        [compare] => LIKE
                                    )
    
                            )
    
                        [2] => Array
                            (
                                [relation] => AND
                                [surface] => Array
                                    (
                                        [key] => tous_lots_2_surface_du_lot
                                        [value] => Array
                                            (
                                                [0] => 42.5
                                                [1] => 172.5
                                            )
    
                                        [type] => numeric
                                        [compare] => BETWEEN
                                    )
    
                                [date] => Array
                                    (
                                        [key] => tous_lots_2_date_de_livraison_du_lot
                                        [value] => 20190931
                                        [compare] => >=
                                        [type] => DATE
                                    )
    
                                [selection_cheminee] => Array
                                    (
                                        [key] => tous_lots_2_etat_de_livraison
                                        [value] => "6-cheminee"
                                        [compare] => LIKE
                                    )
    
                                [non_loue] => Array
                                    (
                                        [key] => tous_lots_2_etat_de_livraison
                                        [value] => "1-loc"
                                        [compare] => LIKE
                                    )
    
                            )
    
                        [3] => Array
                            (
                                [relation] => AND
                                [surface] => Array
                                    (
                                        [key] => tous_lots_3_surface_du_lot
                                        [value] => Array
                                            (
                                                [0] => 42.5
                                                [1] => 172.5
                                            )
    
                                        [type] => numeric
                                        [compare] => BETWEEN
                                    )
    
                                [date] => Array
                                    (
                                        [key] => tous_lots_3_date_de_livraison_du_lot
                                        [value] => 20190931
                                        [compare] => >=
                                        [type] => DATE
                                    )
    
                                [selection_cheminee] => Array
                                    (
                                        [key] => tous_lots_3_etat_de_livraison
                                        [value] => "6-cheminee"
                                        [compare] => LIKE
                                    )
    
                                [non_loue] => Array
                                    (
                                        [key] => tous_lots_3_etat_de_livraison
                                        [value] => "1-loc"
                                        [compare] => LIKE
                                    )
    
                            )
    
                    )
    
            )
    
        [orderby] => Array
            (
                [dept_order] => ASC
                [city_order] => ASC
                [arrdt_order] => ASC
            )
    
    )
    

    I know it’s long, and for now the $max_rows is just 4… it will be around 20 when all the data will be in the DB.

    Looking at the array, it seems it should work…

    Here is my PHP (added with my first post code):

    
    function replace_row($array, $row) {
    	if($array != '') {
    		$array = str_replace('_%_', '_'.$row.'_', $array);
    	}
    	return $array;
    }
    
    $repeater_query = array(relation => 'OR');
    		
    		while ($countposts->have_posts()) {
    			$countposts->the_post();
    			
    			 $count = intval(get_post_meta($post->ID, $repeater, true));
    
    			if ($count > $max_rows) {
    				$max_rows = $count;
    			}
    		}
    		
    		
    	
    		for ($row=0; $row<$max_rows; $row++) {
    			
    			$row_query = array('relation' => 'AND',
    							   'surface' => replace_row($surface, $row),
    							   'date' => replace_row($date, $row),
    							   'selection_cheminee' => replace_row($selection_cheminee, $row),
    							   'non_loue' => replace_row($non_loue, $row)
    								);
    			
    			$repeater_query[] = $row_query; 
    
    		}

    EDIT : here is a clue ->
    – when i set $max_rows = 1; i have no error (but the search only cover the 1st element of each repeater).
    – if i set it with the value “2” it no longer works… Despite the fact that each post has 2 or more element in the repeater field

  • Updated to 5.1.8. Deleted the Page I was adding fields to and started a fresh Field Group. It still won’t save and I get this from WP:

    Warning: Illegal string offset 'acfcloneindex' in /Users/Phil/Sites/augustblume/wp-content/plugins/advanced-custom-fields-pro/pro/fields/repeater.php on line 156
    
    Notice: Array to string conversion in /Users/Phil/Sites/augustblume/wp-content/plugins/advanced-custom-fields-pro/pro/fields/repeater.php on line 156
    
    Warning: Invalid argument supplied for foreach() in /Users/Phil/Sites/augustblume/wp-content/plugins/advanced-custom-fields-pro/pro/fields/repeater.php on line 255

    and then when I try to Add a Row, I get this in the JS:

    [Error] TypeError: undefined is not an object (evaluating '$(this).get(0).outerHTML')
    	outerHTML (acf-input.js, line 288)
    	add (acf-pro-input.js, line 377)
    	doEvent (acf-input.js, line 1866)
    	(anonymous function) (acf-input.js, line 1805)
    	dispatch (jquery.js, line 3)
    	handle (jquery.js, line 3) 
  • Hi!,

    I’m having a similar problem where I try to associate a sub field to a unique ID.

    In the DB, I see that I have a meta_key like repeater_field_0_sub_field where 0 is the order index. If, later on, I change the order of the sub fields, the meta_key become something like repeater_field_2_sub_field and event the meta_id change. So I have no way to “hook” to a sub field.

    Am I missing something?

    Update! I just saw this topic. I’ll probably try to update @gelform ‘s for V5…if there’s no other way 🙂

    Thanks!

    P.S.: Awesome plugin! I use it in all my projects.
    Using ACF Pro V.5

  • ACF is not setting the character limit, that is the WP Database Schema. The options_name field is varchar(64).

    The WP team has been talking about changing this to varchar(255) for 4 years with no action taken, they keep saying, “maybe in the next release”.

    I routinely change this by altering the database and change this column to varchar(255).

    However, when you update WP it will be changed back to 64 and break your site unless you do something to prevent that from happening. Which is why I built this https://github.com/Hube2/wp-update-prevent-db-changes

    Even at 255, you still need to be mindful of how long the option name will get, especially with nested repeaters.

  • Updated method posted at https://www.ractoon.com/2014/11/acf5-pro-color-picker-custom-palettes

    The method below runs into performance issues when combined with repeater/flexible content fields.

    This method has worked for me:

    function my_acf_admin_head() {
    	echo "
    	<script>
    	(function($){
      	acf.add_action('ready append', function() {
      		acf.get_fields({ type : 'color_picker'}).each(function() {
      	  	$(this).iris({
      			  palettes: ['#efefef', '#0093d0', '#235164', '#203051', '#1b2945', '#181717'],
      			  change: function(event, ui) {
      					$(this).parents('.wp-picker-container').find('.wp-color-result').css('background-color', ui.color.toString());
      			  }
      			});
      		});
      	});
    	})(jQuery);
    	</script>
    	";
    }
    
    add_action( 'acf/input/admin_head', 'my_acf_admin_head' );
  • Hello,

    I’m currently facing the same problem. I have a custom post type called ‘events’. Each event has a date, filtering on that is no problem. But each event also has multiple entries (repeater fields) each with a time. I want to be able to filter posts based on that subfield and the current time.

    Did you already find a solution to your problem Jonas?

    I really appreciate any help you can provide.

  • If I understand you correctly, you want to have a field “Add Event”, which will contain repeater fields: first the date on the top row, followed by other fields for details underneath it, so that in one post you could add multiple events on different dates.

    This seems quite straightforward so perhaps I’m missing something. See the attached screenshots for fields setup and appearance. The only thing I changed from default was to change layout from table to row.

    If I’ve misunderstood, could you clarify?

  • This reply has been marked as private.
  • Oh wait this might be working…I am new to PHP….
    notice the instances of “$currMonth != $date->format(‘F’)”, I imagine this makes the function return a string, is that right?

    <?php
                 
                 $repeater = get_field('race_event');
                 foreach( $repeater as $key => $row )
                   { 
                     $column_id[ $key ] = $row['race_date'];
                   } 
                   array_multisort( $column_id, SORT_ASC, $repeater );
                   
                   $currMonth = "start";
                   foreach( $repeater as $row ) :
                   {
                     $date = DateTime::createFromFormat('Ymd', $row['race_date']); 
                     $website_url = $row['race_website'];
                     
                     if ($currMonth != $date->format('F')) :
                       {
                         echo '<h2>' . $date->format('F') . '</h2><br>';
                         $currMonth = $date->format('F');
                       }
                     endif;
                     
                     echo '<ul>';
    		               echo '<li><h2>' . $row['race_name'] . '</h2></li>';
    		               echo '<li>Date ' . $date->format('F d, Y') . '</li>';
    		               echo '<li>Distance ' . $row['race_distance'] . '</li>';
    		               echo '<li>Vertical ' . $row['race_vertical'] . '</li>';
    		               echo '<li>URL <a href=' . $website_url . '> ' . $website_url . ' </a></li>';
    		               echo '<li>' . $row['race_description'] . '</li>';
    		             echo '</ul>';
                   }
                   endforeach;
                   ?>
  • I think this is on the right track but I am getting this error.
    Did I miss something in your example?

    Fatal error: Function name must be a string

    this is my code

    <?php
                 
                 $repeater = get_field('race_event');
                 foreach( $repeater as $key => $row )
                   { 
                     $column_id[ $key ] = $row['race_date'];
                   } 
                   array_multisort( $column_id, SORT_ASC, $repeater );
                   
                   $currMonth = "start";
                   foreach( $repeater as $row ) :
                   {
                     $date = DateTime::createFromFormat('Ymd', $row['race_date']); 
                     $website_url = $row['race_website'];
                     
                     if ($currMonth != $date('F')) :
                       {
                         echo '<h2>' . $date('F') . '</h2><br>';
                         $currMonth = $date('F');
                       }
                     endif;
                     
                     echo '<ul>';
    		               echo '<li><h2>' . $row['race_name'] . '</h2></li>';
    		               echo '<li>Date ' . $date->format('F d, Y') . '</li>';
    		               echo '<li>Distance ' . $row['race_distance'] . '</li>';
    		               echo '<li>Vertical ' . $row['race_vertical'] . '</li>';
    		               echo '<li>URL <a href=' . $website_url . '> ' . $website_url . ' </a></li>';
    		               echo '<li>' . $row['race_description'] . '</li>';
    		             echo '</ul>';
                   }
                   endforeach;
                   ?>
  • Do you mind giving me any tips on formatting and code structure? I am kinda new to PHP and although this works I am not confident.

    One other question I have is, can you recommend a way to approach a UI that would let a user jump to points on the page that are grouped into the same month? Back story is each repeater will have a name and date and now, since I can sort the list by date I was hoping to make it easier for the user to jump to the content for August.

    <!-- repeater	-->
       <?php
         $repeater = get_field('race_event');
           foreach( $repeater as $key => $row )
             { 
               $column_id[ $key ] = $row['race_date'];
              } 
                array_multisort( $column_id, SORT_ASC, $repeater );
                foreach( $repeater as $row ) :
                  {
                    echo '<li>' . $row['race_name'] . '</li>';
    		$date = DateTime::createFromFormat('Ymd', $row['race_date']); 
    		echo '<li>' . $date->format('m-d-Y') . '</li>';
                   }
             endforeach;
         ?>          
    <!-- /repeater	-->
  • Hi Elliot,
    If I put in `
    <?php if(get_field(‘event_programme’)): ?>
    <?php while(has_sub_field(‘event_programme’)): ?> `
    all my fields under event_programme disappear leaving me with just dates and no information under them.
    I imagine I should reference ‘presentation_details’ somewhere in the code in order to pull in all the timetable data. ‘presentation_details’ is my repeater field which contains the details of any one presentation. Maybe I misunderstood your instruction?
    Thanks

  • I use ACF to post consert events. In each post I add playing times using repeater field with date picker. So each event can have multiple dates.

    I manage to order one post by playing dates. But my question is how to sort many posts with different playing times. Order them chronology.

    Actually you reapeat the post content, but with different date.

  • Hi @grobear

    The last thing to do is debug the save function found in core/controllers/post.php on line 488.

    The function save_post will do some validation before running an action called ‘acf/save_post’.

    Step 1: Test that this function is getting past the validation and calling the action

    Next, head to the main acf.php file and on line 839, debug the save_post function there. This is what the post.php file was calling. Does this function loop through , load fields correctly and call the update_vlaue action?

    Hopefully you can find that there is something preventing the data from saving.

    Perhaps you will find that ACF is not getting through the $_POST[‘fields’] loop due to mem issues?

    Thanks
    E

  • P.S. – I purchased the Repeater add-on today. Very nice. It will be very helpful. Was hoping to only need the ACF Plugin for this project but looks like something else/another plugin will need to be implemented for the Events section.

  • Hi Elliot,
    I’m trying to do something similar. I tried the code above and it didn’t work for me.
    I’m trying to create a page with Events Listings. But I’d just like to use one repeater field that has about 6 sub-fields. One of those sub-fields is a selection field called “date_category” with a selection of Current Event and nothing else. So the user would then select if the event is current or if they select nothing, it will go into the archived section of the page. In my template, I’ve duplicated the repeater fields in both selections… see my code…I would actually like to place all the Archived Listings inside a Jquery accordion, so that all the archives would be hidden until the user expands them, but the current events would be listed one after the other, as normal. The problem is that my code creates an accordion for each listing, instead of grouping them all together under one accordion. See my code below. Is there a way to group them?

    Thanks for your help.

    <div class="events">
    <?php if(get_field('event_listings')): ?> 
    <?php while(has_sub_field('event_listings')): ?>
    						
    <?php  if(get_sub_field('date_category') == "Current Event") { ?>
    											    	
    <div class="event_listings">
    <div class="date"><strong>Event Date:</strong> <?php the_sub_field('date'); ?></div>	
    <div class="title"><?php the_sub_field('title'); ?></div>
    
    <p><?php the_sub_field('description'); ?></p>
    															
    <div class="meta"><strong>Time:</strong> <?php the_sub_field('time'); ?></div>
    <div class="meta"><strong>Location:</strong> <?php the_sub_field('location'); ?></div>
    <div class="meta"><strong>Attendance:</strong> <?php the_sub_field('attendance'); ?></div>
    <div class="meta"><strong>Type:</strong> <?php the_sub_field('type'); ?></div>
    </div><!--End Event Listings-->
    							
    
    <?php  } else { ?>
    							
    <div class="expand">Archived Listings</div>
    							
    <div class="event_listings collapse">
    <div class="date"><strong>Event Date:</strong> <?php the_sub_field('date'); ?></div>	
    <div class="title"><?php the_sub_field('title'); ?></div>
    																		
    <p><?php the_sub_field('description'); ?></p>
    															
    <div class="meta"><strong>Time:</strong> <?php the_sub_field('time'); ?></div>
    <div class="meta"><strong>Location:</strong> <?php the_sub_field('location'); ?></div>
    <div class="meta"><strong>Attendance:</strong> <?php the_sub_field('attendance'); ?></div>
    <div class="meta"><strong>Type:</strong> <?php the_sub_field('type'); ?></div>
    </div><!--End Event Listings-->
    							
    <?php } ?>
    						
    							
    <div style="margin-bottom:20px;"></div>
    <?php endwhile; ?> 
    <?php else : ?>
    <p>There are no event listings at this time.</p>
    <?php endif; ?>					
    </div>	
  • Hi @joostvanhoof

    Yes, it would be possible to hook into the acf/update_value filter and update or remove connections based on the $value.

    This would be a very good solution, however, will require some complex coding which will be up to you.

    As to your previous statement regarding post ID / object:
    The relationship field will always save the ID’s, never any information about the actual $post. No change will be made to the DB by this option, only the returned value via get_field.

    Basically, having the relationship field within the repeater prevents querying from being possible. If the relationship field is on the root level, then yes, you can easily query backwards and forwards from artists to events (there is a tutorial for this on the docs page).

    I use p2p in my advanced websites and also, so does bbPress – the wordpress forum plugin!

    Good luck

    Cheers
    E

  • I just gave p2p a shot and it indeed does exactly what I want.

    Going through the documentation, I’ve found this (see here):

    // Create connection
    p2p_type( 'YOUR_CONNECTION_TYPE' )->connect( $from_id, $to_id, array(
    	'date' => current_time('mysql')
    ) );
    
    // Delete connection
    p2p_type( 'YOUR_CONNECTION_TYPE' )->disconnect( $from_id, $to_id );

    It is possible to use ACF with my setup as described above (artists custom post types as relationship fields in repeater fields) and then add the above p2p code when I’m adding and deleting artists?

    Because then I can:

    • Use my preferred ACF setup (relationship fields in repeater fields)
    • Which results in that I don’t have to use the p2p admin box for adding artists
    • I can use the p2p queries which solves my querying problem!

    The only question that remains is: what happens when I add an artist in one repeater block, and then add the same artist in another repeater block? The documentation of p2p says about the code above: ‘The advantage of using this API is that it enforces all the rules you set when defining the connection type, such as ‘prevent_duplicates’ and ‘cardinality’.’ So I guess it will check for duplicates? The link to this p2p documentation here.

    I think we’re almost there :-).

Viewing 20 results - 251 through 270 (of 270 total)