Support

Account

Home Forums Search Search Results for 'date picker'

Search Results for 'date picker'

topic

  • Unread

    Display ACF Taxonomy fields by id custom-post-type in a React App with Rest API

    Hello,
    i hope if some of you could help me

    i Have a custom post type (project)
    each ‘project’ has a custom taxomony (area_project)
    this taxonomy has a ACF field ‘color-picker'(colore)

    how can i display this field (colore) in a react map?

    in function.php i’m trying something with register_rest_field, but i can’t connect the taxonomy with the post id
    the following code return my only the ACF fields of the post , not the field in taxonomy connected to the post

    
    function register_rest_project_fields(){
        register_rest_field(
      		[ 'post', 'page', 'project', 'area_project' ], // add post types here
      		'acf_fields', // name of the field
      		array(
      			'get_callback'    => 'get_acf_fields_for_api',
      			'update_callback' => null,
      			'schema'          => null,
      		)
      	);
    }
    function get_acf_fields_for_api( $object, $field_name, $request ) {
    	$data = get_fields( get_the_ID() );
    	return $data ?: false;
    }
    add_action('rest_api_init', 'register_rest_project_fields' );
    

    Some of you have some solution?
    Thanks in advance

  • Solved

    Auto Update Field based on ACF Date Picker field

    Hey everyone,

    i really need some help with my code.

    I have a custom post type named “coupon”. With ACF i added two fields. The first is a Date Picker field named “coupon_valid_till” with my expiration Date. The second one is a true/false field named “is_expired”. I want to change the value of the true/false field to false if the expiration date is reached.

    First i saw this thread:

    https://support.advancedcustomfields.com/forums/topic/auto-update-fields-based-on-expired-date/

    But that didn´t work.

    I then found this pretty similar thread:

    https://support.advancedcustomfields.com/forums/topic/publish-expire-posts-based-on-acf-date-picker-field/

    From the Answers in the Thread, this code should work. But i don´t need to change the Post from public to draft. So i changed this:

      if (($expiredate < $today) && ($expiredate != "")) { // if date is less than today, but also not empty to accomodate the coupons that don't expire
                    $postdata = array(
                        'ID' => $p->ID,
                        'post_status' => 'draft'
                    );
                    wp_update_post($postdata);
                 }      

    to that:

      if (($expiredate < $today) && ($expiredate != "")) { // if date is less than today, but also not empty to accomodate the coupons that don't expire
                  update_field('is_expired', 0, $post->ID);
                 }      

    But it dint´t work either. I managed to setup a cronjob for the code, which gets executed – but nothing happens.

    It would be great if someone could help me.

    Kathi

  • Helping

    Order products first which have field

    Hello, in woo products i have added repeater (pasirinkti_datas) and in repeater are datepicker field (keliones_datos). How i can order products first which have datepicker field? Also i need to order products from nearly date to latest. Also one product can have multiple dates.
    This is Example what i need:

    +Product (2022-12-24)
    +Product (2022-12-26)
    +Product (2022-12-29)
    +Product (without date)
    +Product (without date)
    ….

    I have added this code into functions.php

    
    add_filter('woocommerce_get_catalog_ordering_args', 'woocommerce_catalog_orderby');
    function woocommerce_catalog_orderby( $args ) {
    	$args['meta_key'] = 'pasirinkti_datas_0_keliones_datos'; 
    	        $args['order']    = 'ASC'; 
    	 $args['orderby']  = 'meta_value_num';
    
        return $args;
    }
    

    But it now only shows posts with dates, posts that don’t have dates disappear.

    Also, first repeater row is always the earliest date, so i think my meta_key can be ‘pasirinkti_datas_0_keliones_datos’.

  • Helping

    Change/set a datepicker date with Javascript

    The ACF Javascript API does not allow the setting of a datepicker date programmatically.

    acf.getField('the_field_id').val([the date]); // does not work
    // nor does set()

    Nor do any of the usual workarounds to change the value of the jQuery UI datepicker.

    Surely they wouldn’t have written a datepicker object where you can’t programmatically change the date?

    Does anyone have a workaround?

  • Solving

    Delete repeater`s sub_field after expired date

    Hello, i have repeater (‘pasirinkti_datas’), and in this repeater are stored datepicker (‘keliones_datos’) Y-m-d format.

    I need to do a function that deletes repeater row if datepicker date is lower than todays date

  • Solved

    ACF6 + register_block_type + assets

    In the past i could write this:

    acf_register_block_type(array(
    			'name'              => 'quickbooker',
    			'title'             => __('Quickbooker','lmdm'),
    			'description'       => __('Buchungsformular','lmdm'),
    			'render_template'   => plugin_dir_path( dirname( __FILE__ ) ).'template-parts/blocks/quickbooker/index.php',
    			'category'          => 'widgets',
    			'icon'              => 'calendar-alt',
    			'mode'              => 'preview',
    			'enqueue_assets' => function(){
    				wp_enqueue_style( 'daterangepicker.css' );
    				wp_enqueue_script( 'moment.min.js', array('jquery'), '', true );
    				wp_enqueue_script( 'block-qb-daterange', 'daterangepicker.js', array('jquery'), '', true );
    				wp_add_inline_script('block-qb-daterange','jQuery(document).ready(function($) { $(".dates").daterangepicker( { autoUpdateInput: false, autoApply: true, showISOWeekNumbers: true, minDate: "'.date_i18n("d.m.Y", strtotime("+1 day")).'",locale: { format: "DD.MM.YYYY", firstDay: 1, daysOfWeek: ["So","Mo","Di","Mi","Do","Fr","Sa"], monthNames: ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],applyLabel: "speichern",cancelLabel: "abbrechen"} } ).on("apply.daterangepicker", function(ev, picker) { $(this).val(picker.startDate.format("DD.MM.YYYY")+" - "+picker.endDate.format("DD.MM.YYYY")); $(this).closest("form").find("input[name=arrival]").val(picker.startDate.format("DD.MM.YYYY")); $(this).closest("form").find("input[name=departure]").val(picker.endDate.format("DD.MM.YYYY")); }) });');
    				wp_enqueue_script( 'block-qb-script', 'script.js', array('jquery'), '123', true );
    				
    			}
    		));

    now i try to convert it according to ACF6 to use the native “register_block_type” function. How can i enqueue multiple javascript assets? This works:
    i need to write wp_enqueue_script(“my_handle”…) in functions.php then i can call it in the block.json like: script: “my_handle”.
    But how to call the other assets as well?
    this works NOT:
    script: [“my_handle”,”another_handle”]
    this will trigger a fatal error. and how to take dependencies into account?

    and when i add acf key into the block.json file, phpstorm shows “Property acf is not allowed”. How to validate the json file then?

  • Solved

    Date Picker Range of Years +-100 but I need more

    Hi,

    currently the date picker has a range of plus minus 100 years to the current year. But I need more. Is there any filter that could be used to modify this?

    Thanks Sascha

  • Unread

    Front End form

    Hello,

    I am using the function “acf_form()” to add data directly on the front end of my website but there are two fields that doesn’t work which are :

    Date picker
    Post Object field

    There is no error on the website neither on the console, everything works well except that
    the function acf_enqueue_uploader(); and acf_form_head(); are in place I don’t know what it can be

    Thank you !

  • Helping

    Remaining Days Calculation

    I have a custom post type called Contracts and each contract has an expiry date (ACF date picker). I am trying to calculate the remaining days of expiry and display it on a custom field.

    Here is my code. When I run the cron job, it shows the remaining days as 19213 for a contract with expiry date of 31/12/2022. Can anyone guide me on how to correctly display the remaining days?

    function wpf11144133_contracts_expiry_time() {
    
    $date_to    = get_field( 'valid_until');
    $date_expiry     = new DateTime(date('Y-m-d ', strtotime($date_to)));
    $date_today = new DateTime(date('Y-m-d ', strtotime('today')));
    
    $days = $date_expiry->diff($date_today)->days;
       
    	$posts = get_posts( array(
    		'post_type'			=> 'contract',	// Contract post type
    		'post_status' 		=> 'publish',	// Only grab published posts
    		'posts_per_page'	=> -1,			// Grab all posts
    		'no_found_rows'		=> true,		// Don't calculate pagination, we don't need it
    		'update_cache'		=> false,		// Don't need to cache results
    		'meta_query'		=> array(
    			array(
    				'key'		=> 'status',
    				'value'		=> 'Valid',
    				'compare'	=> '=',	
    			)
    			),
    	) );
    	if( ! empty ( $posts ) ) {
    
    		foreach( $posts as $post ) {
    
    			update_field('remaining_days',$days, $post->ID);
    
    		}
    	}
    }
    add_action( 'wpf11144133_contracts_expiry_time_calculation_job', 'wpf11144133_contracts_expiry_time' );
  • Solving

    I want to show D-day using date picker

    I try to make site with elementor pro and advanced custom field pro.

    I want to show D-day related to the date picker

    For example, when I check the date picker 2022.08.20 and if today is 2022.7.31 I want to show the D-day as D-20

    Is there any way I can do that?

    Thanks for the good support

  • Solving

    Conflict with Tribe Events Calendar date picker and time picker

    This issue just popped up in the last few weeks for me with Tribe Events Calendar.

    When both ACF and TEC are activated at the same time, date and time picker fields no longer work as expected. The pickers don’t appear and the input values change to random dates on blur.

    Reference:
    date is borked

    Looking into further details at the moment, but hoping I’m not the only one in the meantime.

    WP 6.0, PHP 7.4, Twentytwentytwo, latest versions of each plugin

  • Unread

    How to sort by Year and then by Month? Repeater and Data Picker.

    
    <?php if( have_rows('roadmap_repeater2') ): ?>
        <section class="roadmap">
            <div class="container">
                <?php
                $repeater = get_field('roadmap_repeater2');
                $roadmapBlock = array();
                foreach( $repeater as $key => $row ) :
                    $column_id = $row['roadmap_repeater2_date'];
                    $second_date_string = DateTime::createFromFormat('d/m/Y', $column_id );
                    $second_date = $second_date_string->format('m/Y');
                    $roadmapBlock[$key] = $second_date;
                endforeach;
                array_multisort( $roadmapBlock, SORT_DESC, $repeater );
    
                $currMonth = "start";
                foreach( $repeater as $row ): ?>
                    <?php $second_date = DateTime::createFromFormat('d/m/Y', $row['roadmap_repeater2_date']); ?>
                    <?php if ($currMonth != $second_date->format('Y')): ?>
                        <div class="roadmap__header">
                            <h2 class="roadmap__heading"><?php echo $second_date->format('Y'); ?></h2>
                        </div>
                        <?php $currMonth = $second_date->format('Y'); ?>
                        <div class="roadmap__item">
                            <time class="roadmap__time" datetime="<?php echo $row['roadmap_repeater2_date']; ?>">
                                <?php echo $second_date->format('m/Y'); ?>
                            </time>
                        </div>
                    <?php else: ?>
                        <div class="roadmap__item">
                            <time class="roadmap__time" datetime="<?php echo $row['roadmap_repeater2_date']; ?>">
                                <?php echo $second_date->format('m/Y'); ?>
                            </time>
                        </div>
                    <?php endif; ?>
                <?php endforeach; ?>
            </div>
        </section>
    
    <?php endif; ?>
    
  • Helping

    Sort rows by Date Picker

    I have a repeater field and in each row I have a field to select a date(Date Picker). I want to sort the rows by years and automatically add the year as a header taken from the Date Picker field.

  • Unread

    Output localized date in a customized format

    Hello,

    I’m using a Date Picker field to save a date value.

    I can output the field value with get_field, but if I want to output a customized output localized I didn’t find any solution.

    I want to output the day first, then month+year in custom HTML. I tried to use DateTime::createfromFormat which is working but is outputing an english version of the date.

    <?php 
    if($full_date = get_field('date')):
    	$day_from_date = DateTime::createFromFormat('d/m/Y', $full_date)->format('d');
    	$monthyear_from_date = DateTime::createFromFormat('d/m/Y', $full_date)->format('M Y');
    	echo $day_from_date ;
    	echo $monthyear_from_date ;
    endif;?>

    How can I output the localized version for a customized output date ?
    Thank you in advance.

    Frédéric

  • Unread

    Resaving post changes Date Time Picker time

    Hello,

    I have a Date Time Picker field and every time I resave the post and the page refreshes, the new value is +5 hours. Consequently, if I then resave the post, the +5 hour time is saved and the process repeats. If the +5 hours go past 24:59, the date also changes to the next day.

    When I go to initially set the field’s value and click “Now”, it loads the correct date and time.

    Here is a link to a screen recording: https://imgur.com/a/1VXzwo1

    Any idea what’s going on? Is there an issue with the timezone?

    ACF Pro version 5.12.2

  • Solving

    Generate post title from two ACF fields

    This is probably so simple for you all…

    I have a custom post type called Job Updates (slug is job_updates)

    It has 3 fields…

    Job – a taxonomy
    Date – date picker
    Update – WYSIWYG

    I would like the title of the post to auto generate based on the Job + Date
    So if the job is Sherman Water Damage, it would be Sherman Water Damage 6-1-2022

    I’ve searched the forum and tried several different functions in the Snippets app, while swapping out their variables for mine, but none seem to work. I don’t know php, so that might be part of it.

  • Helping

    The datepicker field of the post type it is relationship to is not showing

    I want to show the datepicker field of the post type it is associated with in cpt, but it is not working.

    Event post type has “Start date” and “End date” fields.
    On the Season post type single page, I list the event post type and I want to show the dates.

    I am using the following example:

    <?php 
    
    // Load field value.
    $start_date = strtotime (get_field('start_date'));
    $end_date = strtotime (get_field('end_date'));
    
    ?>
    <h4><?php echo date_i18n( "F j", $start_date ); ?> - <?php echo date_i18n( "F j", $start_date ); ?></h4>
    <p><?php echo date_i18n( "H:i", $end_date ); ?> - <?php echo date_i18n( "H:i", $end_date ); ?></p>
  • Unread

    Snippet with ACF field and Woocommerce stock

    Hi there,

    I’m trying to get this code to work in my functions.php, but I’m missing something where I get the posts I guess.
    Products have a few ACF field, including one called ‘date_of_event’. That’s a datepicker field. I want to hide all products that are out of stock and the date has past. For the products where the stock is 0, but the date in the future I want to display them (don’t hide).
    Can anyone check my code and tell me what I am missing?

    add_filter( 'pre_option_woocommerce_hide_out_of_stock_items', 'bbloomer_hide_out_of_stock_exception_page' );
     
    function bbloomer_hide_out_of_stock_exception_page( $hide ) {
    		$sDate = get_field('date_of_event');
    		$currendDate = date('Ymd');
    		if($sDate > $currendDate){
          $hide = 'no';
       }   
       return $hide;
    }
  • Helping

    Display Posts from sub-post Repeater Field

    I am having a hard time with something and hoping I can get a little assistance. Here is my goal:
    I have a web site where we put on multiple Events in various locations which inlcude Artist Instructors (primarily musicians) which change every year. We want to be able to provide a page where someone can go and see who taught at each location/year combo. Or to filter the list. I believe I need to do the following to make this work:

    • Have a Primary “Festival” page which has some information which can be over-written each year. Include metadata via ACF for the Location (A Clone field from the Overview post below so I do not have to edit Locations in multiple places) and the current Year (date picker formatted as YYYY only) we are registering people for.
    • Have a Post for each Artist wich is a Biography and includes an ACF field for their “Instrument”
    • Have an Overview Post which includes detailed information for teh current Year and a Repeater field for selecting Post Objects for the Biographies. I am using the Repeater field so we can set the Order in which the Biographies appear. This Overview post has ACF fields for
    • Location
    • Start Date (date picker)
    • End Date (date picker)
    • Artists (Repeater with a Post Object Subfield called Artist)
    • So Iam trying to create a Template for the Main Page. I can pull the appropriate Overview Post, but I am not getting the Artist Posts (Biographies) to display. I get the Title as a link for the First of Three in the list. After that I get 23 listings with no Title/Link and only the text for teh custom field with no entry (actually a foreach error but that is likely because some other data is being returned). Any idea where I may be off on this?

      Code:

      <?php
      /**
       * The template for displaying the primary festival location pages
       *
       * Template Name: Festival Main
       * 
       * @package WordPress
       * @subpackage Boxwood\\
       * @since Twenty Twelve 1.0
       */
      get_header();
      ?>
      	<div id="container">
      		<div id="content">
      			<div id="main-column-full-width">
      				<?php /* The entry content */ ?>
      				<div class="entry-content">
      					<?php if(!is_front_page()) {?>
      						<?php if ( function_exists('yoast_breadcrumb') ) {
      							yoast_breadcrumb('<p id="breadcrumbs">','</p>');
      						} ?>
      						<h1 class="entry-title"><?php the_title(); ?></h1>
      					<?php }?>
      
      					<?php
                          if (have_posts()) :
                              while (have_posts()) :
                                  the_post();
      						    the_content();
      					    endwhile;
      					endif;
      					?>
      
      <h1>Start Latest</h1>
      
      <?php
      /**
       * Get the Overview Post to pull data for retrieving other posts, etc
       */
      $my_location = get_field('location_location');
      $my_year = get_field('year');
      
      $startyear = $my_year . '0000';
      $endyear = $my_year + 1 . '0000';
      
      $args = array(
          'numberposts'	=> -1,
          'post_type' => 'post',
          'category_name' => 'festival-overview',
          'meta_query' => array(
              array(
                  'key'     => 'location',
                  'value'   => $my_location,
              ),
            array(
              'key' => 'start_date',
              'value' => $startyear,
              'compare' => '>'
            ),
            array(
              'key' => 'start_date',
              'value' => $endyear,
              'compare' => '<'
            )
          )
      );
      $overview_posts = new WP_Query( $args );
      
      // Show the Overview Post content
      if ( $overview_posts->have_posts() ) :
          while ( $overview_posts->have_posts() ) :
              $overview_posts->the_post();
                  
              // Check rows exists.
              if( have_rows('artists') ):
                  // Loop through rows.
                  while( have_rows('artists') ) : the_row();
      
                      // Load sub field value.
                      $featured_posts = get_sub_field('artist');
                      if( $featured_posts ): ?>
                          <ul>
                              <?php foreach( $featured_posts as $post ): 
              
                                  // Setup this post for WP functions (variable must be named $post).
                                  setup_postdata($post); ?>
                                  <li>
                                      <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                      <span>A custom field from this post:
                                          <?php
                                              $my_instrumentsarray = get_field('intruments');
      	                            	    foreach ($my_instrumentsarray as $my_instrument) {
                      	                        echo $my_instrument ;
                      	                } ?>
                      	            </span>
                                  </li>
                              <?php endforeach; ?>
                          </ul>
                          <?php 
                          // Reset the global post object so that the rest of the page works correctly.
      //                    wp_reset_postdata();
                      endif;
               endwhile;
              endif;
          endwhile;
      
          while ( $overview_posts->have_posts() ) :
              $overview_posts->the_post();
                  if ( has_post_thumbnail() ) :
                      the_post_thumbnail();
                  endif;
                  ?>
                  <div class="entry-content">
                      <?php the_content(); ?>
                  </div>
              </article>
              <?php
          endwhile;
      
      endif;
      
             
      // Restore original post data.
      wp_reset_postdata();
      
      ?>
      
      				</div><!-- .entry-content -->
      			</div><!-- #main-column-full-width -->
      		</div>
      	</div><!-- #container -->
      	
      	<?php get_footer(); ?>
  • Solving

    Get Total of Matching Fields in Repeater Within Custom Query

    Hey everyone!

    I’m setting up a site and have run into a wall. I have three custom post types: clients, flowers, hard_goods. The ACF set up is the following: Wedding Date (date picker), Flowers Count List (field name:’flowers_count_list’ – Repeater) that contains Flowers (field name: ‘flowers’ – relationship to cpt of flowers) and Flowers Count (field name: ‘flowers_count’ – number used per client). I have the archive page set up to display posts within a date range but I’m looking to get a total of the ‘flowers_count’ matching flowers by their name ‘flowers’ then a breakdown by wedding underneath that, all in alphabetical order.

    Example:
    Delilah: 12

    • Client 2 – 6 Delilah
    • Client 4 – 4 Delilah
    • Client 5 – 2 Delilah

    Roses: 5

    • Client 1 – 3 Roses
    • Client 2 – 2 Roses

    Tulips: 15

    • Client 3 – 10 Tulips
    • Client 5 – 5 Tulips

    Here’s the code I currently have that’s showing the individual breakdown by client.

    
    add_action('wp_ajax_myfilter', 'misha_filter_function'); // wp_ajax_{ACTION HERE} 
    add_action('wp_ajax_nopriv_myfilter', 'misha_filter_function');
    
    function misha_filter_function(){
        $args = array(
            'post_type'         => 'clients',
            'meta_key'          => 'wedding_date',
            'orderby'           => 'meta_value',
            'order' => $_POST['date'] // ASC or DESC
        );
     
        // for taxonomies / categories
        if( isset( $_POST['categoryfilter'] ) )
            $args['tax_query'] = array(
                array(
                    'taxonomy' => 'category',
                    'field' => 'id',
                    'terms' => $_POST['categoryfilter']
                )
            );
     
        // create $args['meta_query'] array if one of the following fields is filled
        if( isset( $_POST['start_date'] ) && $_POST['start_date'] || isset( $_POST['end_date'] ) && $_POST['end_date'] || isset( $_POST['featured_image'] ) && $_POST['featured_image'] == 'on' )
            $args['meta_query'] = array( 'relation'=>'AND' ); // AND means that all conditions of meta_query should be true
     
        // if both minimum price and maximum price are specified we will use BETWEEN comparison
        if( isset( $_POST['start_date'] ) && $_POST['start_date'] && isset( $_POST['end_date'] ) && $_POST['end_date'] ) {
            $args['meta_query'][] = array(
                'key' => 'wedding_date',
                'value' => array( $_POST['start_date'], $_POST['end_date'] ),
                'type' => 'date',
                'compare' => 'between'
            );
        } else {
            // if only min price is set
            if( isset( $_POST['start_date'] ) && $_POST['start_date'] )
                $args['meta_query'][] = array(
                    'key' => 'wedding_date',
                    'value' => $_POST['start_date'],
                    'type' => 'date',
                    'compare' => '>'
                );
     
            // if only max price is set
            if( isset( $_POST['end_date'] ) && $_POST['end_date'] )
                $args['meta_query'][] = array(
                    'key' => 'wedding_date',
                    'value' => $_POST['end_date'],
                    'type' => 'date',
                    'compare' => '<'
                );
        }
    
     
        // if post thumbnail is set
        if( isset( $_POST['featured_image'] ) && $_POST['featured_image'] == 'on' )
            $args['meta_query'][] = array(
                'key' => '_thumbnail_id',
                'compare' => 'EXISTS'
            );
        // if you want to use multiple checkboxed, just duplicate the above 5 lines for each checkbox
     
        $query = new WP_Query( $args );
        
        if( $query->have_posts() ) :
    
        echo '<div class="wedding-clients-gallery">';
    
        while( $query->have_posts() ): $query->the_post();
    
                echo '<div class="client-wedding"><a href="';
                    the_permalink();
                echo '"><h2>';
                the_title();
                echo '</h2></a> date: ';
                the_field('wedding_date');
    
        // Check rows exists.
        if( have_rows('flowers_count_list') ):
        
        echo '<h3>Flowers List:</h3>';
    
            // Loop through rows.
            while( have_rows('flowers_count_list') ) : the_row();
    
        $featured_posts = get_sub_field('flowers');
    
        if( $featured_posts ): ?>
        <ul>
        <?php foreach( $featured_posts as $post ): 
    
            // Setup this post for WP functions (variable must be named $post).
            setup_postdata($post); ?>
            <li>
                <?php
                echo get_the_title( $post->ID );
                echo '( ';
                the_sub_field('flowers_count');
                echo ' )';
                ?>
            </li>
        <?php endforeach; ?>
        </ul>
        <?php 
        // Reset the global post object so that the rest of the page works correctly.
        wp_reset_postdata();
    
        endif;
            // End loop.
            endwhile;
    
            // No value.
            else :
                // Do something...
            endif;
    
    // Check rows exists.
        if( have_rows('hard_goods_count_list') ):
        
        echo '<h3>Hard Goods List:</h3>';
    
            // Loop through rows.
            while( have_rows('hard_goods_count_list') ) : the_row();
    
        $featured_posts = get_sub_field('hard_goods');
    
        if( $featured_posts ): ?>
        <ul>
        <?php foreach( $featured_posts as $post ): 
    
            // Setup this post for WP functions (variable must be named $post).
            setup_postdata($post); ?>
            <li>
    
                <?php
                echo get_the_title( $post->ID );
                echo '( ';
                the_sub_field('hard_goods_count');
                echo ' )';
                ?>
            </li>
        <?php endforeach; ?>
        </ul>
        <?php 
        // Reset the global post object so that the rest of the page works correctly.
        wp_reset_postdata();
    
        endif;
            // End loop.
            endwhile;
    
            // No value.
            else :
                // Do something...
            endif;
    
                echo '</div>';
            endwhile;
    
            echo '</div>';
    
            wp_reset_postdata();
        else :
            echo 'No posts found';
        endif;
        
        die();
    }
    

    Thank you for reading through this and the potential help!

  • Solving

    Sorting woocommerce products by ACF Date Picker field

    Hello everyone,

    I’m stuck with this problem and I will really appreciate any kind of help.
    For woocommerce products I have created a custom field “date_end” and I like to order the products based on that value. The custom field type is Date Picker with Display Format: d/F/Y and Save Format: dd/MM/yy.

    I’m using this function to order the products:

    add_filter('woocommerce_get_catalog_ordering_args', 'woocommerce_catalog_orderby');
    function woocommerce_catalog_orderby( $args ) {
            $args['order']    = 'ASC'; 
            $args['meta_key'] = 'date_end'; 
            $args['orderby']  = 'meta_value';
    
        return $args;
    }

    But this is not ordering correctly. For example, I have products with dates: 3 September 2021, 22 February 2022, 01 April 2022.
    Instead of that correct ordering, I have: 01 April 2022, 03 September 2021, 22 February 2022

    So I guess that the ordering is made only based on the day ( 1,3,22) and the month and the year are not considered. I really don’t know what’s causing this issue. Thanks.

  • Unread

    Updating sub-field with another sub-field

    Hi,

    I want to put array into meta_value in wp_postmeta table, I have front-end form and I update_post_meta with get_field with repeater as a selector. In this repeater i have date_picker with name date and group with two date_pickers named newdate.

    If I name group and date_picker the same I can’t get data from front-end form, so i named it differently and I wanted to override “date” with “newdate” data i tried to use have_rows() with

    $sub_value = get_sub_field('newdate');
                update_sub_field("date", $sub_value);
                delete_sub_field('newdate');

    But it doesnt work, do you have any ideas how can i update date field with newdate subfield and delete it after before i send data with post and use get_field + update_post_meta to populate wp_postmeta table?

    Here’s array of what get_field gives me:

    Array
    (
        [0] => Array
            (
                [type] => date
                [date] => 2022-02-10
                [newdate] => Array
                    (
                        [0] => 
                        [1] => 
                    )
    
                [price] => 124
                [sale_price] => 421
                [unit] => 
            )
    
        [1] => Array
            (
                [type] => daterange
                [date] => 
                [newdate] => Array
                    (
                        [0] => 2022-02-16
                        [1] => 13/02/2022
                    )
    
                [price] => 436643
                [sale_price] => 634643
                [unit] => single
            )
    
    )
  • Unread

    Order Query by Time Picker not working

    Hi,

    I’ve got a query of posts which is returning the correct posts for a particular day but when I try and order the query using an ACF Time Picker field it doesn’t sort them correctly.

    Im using code:

    	// Set Post Type
    	$query->set( 'post_type', [ 'sessions' ] );
    	
    	// Set Posts per page
    	$query->set( 'posts_per_page', -1 );
    	
    	// Get current meta Query
    	$meta_query = $query->get( 'meta_query' );
    
    	// If there is no meta query when this filter runs, it should be initialized as an empty array.
    	if ( ! $meta_query ) {
    		$meta_query = [];
    	}
    
    	// Set Query Dates
    	$qry_offset_monday = $_GET['offset'];
    	if (!$qry_offset_monday) $qry_offset_monday = 0;
    
    	$str_monday = "monday this week +" . $qry_offset_monday . " week";
    	
    	$date_monday = date('Ymd', strtotime($str_monday));
    	
    	// Append our meta query
    	$meta_query[] = [
    		'key' => 'session_date',
    		'value' => $date_monday,
    		'type' => 'DATE',
    	];
    
    	$query->set( 'meta_query', $meta_query );
    	
    	// Set Ordering
    	$query->set( 'order', [ 'ASC' ] );
    	$query->set( 'orderby', [ 'meta_value_time' ] );
    	$query->set( 'meta_key', [ 'session_time' ] );
    	$query->set( 'meta_type', [ 'TIME' ] );
    

    I’ve tried using orderby set to meta_value, meta_value_num and meta_value_time and nothing seems to work.

    I’d appreciate any help that anyone could give.

  • Unread

    Filtering my products by my new Custom Date

    Hi y’all.

    I added a new custom date to my product. I’ve named it Departure Date.

    Now I’d like to add a product filter by this new Departure Date with a date picker. Did anybody did sokething similar yet?

    Thanks

  • Solved

    Upcoming events are not getting displayed for time picker

    We have an events custom post type and trying to display the posts as upcoming events with the below query posts.

    we have custom date and time picker fields to set the event date and time.

    it displays correct upcoming events for date, but $time clause is not working.

    $time = date("H:i:s"); // 17:16:18
    
          if (trim($session_setting) == 'upcoming') {
    
            $args = array(
    
              'post_type'=> 'livesession',
              'post_status' => 'publish',
              'posts_per_page' => 99,
              'paged' => $paged ,
              'order'     => 'ASC',
              'orderby'   => 'meta_value_num',
              'meta_query' => array(
              	'relation' => 'AND',
                  'date_clause' => array(
                    'key' => 'session_date',
                    'compare'	=> '>=',
                    'value'   => $today,
                  ),
                    'time_clause' => array(
                    'key' => 'session_time',
              	'compare'	=> '>=',
                    'value'   => $time,
    
                  ),
    
              )
            );
          }
Viewing 25 results - 51 through 75 (of 787 total)