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’.
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?
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
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?
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
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 !
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' );
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
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:
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
<?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; ?>
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.
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
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
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.
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>
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;
}
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:
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(); ?>
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
Roses: 5
Tulips: 15
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!
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.
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
)
)
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.
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
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,
),
)
);
}
Hi all,
I’m currently having issues running queries based on the Date Picker field and comparing this with the current date. I’ve opted to set the Return Format to “U” so that it returns a string which I can then compare to a string version of the current date.
What I would like to do is display content on certain pages based on this comparison (greater than current date for “coming soon” and also the opposite for “now showing”). However, it seems that the data is getting very mixed up as I have content that should be on “now showing” which is displaying on “coming soon” instead.
In addition I have the page split so that I can use an ACF to set certain films to be “featured” and therefore not show up in the lower results as well.
Below is the code I have so far and a live deployment can be viewed on the following.
<?php
get_header();
?>
<!-- START - Coming Soon -- Header -->
<section class="comingsoon-header">
<h1 class="section__heading">Coming Soon</h1>
<!-- START - Coming Soon Slider -->
<?php
$dateToday = date("U"); ?>
<p><?php echo $dateToday ?></p>
<?php
$comingSoonFilms = new WP_Query(array(
'post_type' => 'film',
'posts_per_page' => -1,
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'film_releasedate',
'value' => $dateToday,
'type' => 'DATE',
'compare' => '>',
),
array(
'key' => 'film_active',
'value' => '1',
),
)
));
?>
<?php if ($comingSoonFilms->have_posts()) : ?>
<!-- START - Coming Soon Slider -->
<div class="section__slider-container text-center">
<div class="swiper swiper-container swiper--section swiper--section--filmswide swiper--section--filmswide--comingsoon">
<div class="swiper-wrapper">
<!-- Slides -->
<?php while ($comingSoonFilms->have_posts()) {
$comingSoonFilms->the_post();
if (get_field('film_comingsoon_featured_status') == true) {
?>
<div class="swiper-slide">
<a href="<?php the_permalink(); ?>">
<img src="<?php the_field('film_comingsoon_featured_image'); ?>" alt="" title="" class="swiper__imgbg" />
<div class="comingsoon-header__details">
<p class="comingsoon-header__details__heading"><?php the_title() ?> </p>
<span class="cta">View More</span>
<p class="comingsoon-header__releasedate"><i class="fas fa-clock"></i>Coming: <?php echo date('d/m/Y', get_field('film_releasedate')) ?><br />
<br /><?php echo get_field('film_releasedate') ?></p>
</div>
</a>
</div>
<?php
}
}
?>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
</div>
<!-- END - Coming Soon Slider -->
</section>
<!-- START - Coming Soon -- More -->
<section>
<h2 class="section__heading">More Coming Soon</h2>
<div class="filmpanels filmpanels--grid">
<?php while ($comingSoonFilms->have_posts()) {
$comingSoonFilms->the_post();
if (get_field('film_comingsoon_featured_status') == false) {
?>
<div>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<img src="<?php echo wp_get_attachment_url(get_field('film_poster')); ?>" alt="" title="" class="swiper__imgbg" />
<p><?php the_title(); ?></p>
<?php echo date('d/m/Y', get_field('film_releasedate')) ?>
<p><?php echo get_field('film_releasedate') ?></p>
</a>
</div>
<?php
}
}
?>
</div>
</section>
<section class="results--pagination">
<?php
echo paginate_links(array(
'total' => $comingSoonFilms->max_num_pages
));
wp_reset_query();
?>
<?php else : ?>
<p>No films currently coming soon!</p>
<?php endif; ?>
</section>
<?php
get_footer();
?>
https://apexcinemas.andrewcourtney.co.uk/coming-soon/
Thanks in advance
I’ve created an Events post type that is categorized using two taxonomies: Event Type and Academic Program
I’m able to create list of Event posts and include a filter form to pull up specific events categories based on what’s selected in two drop down selections.
I want to filter the page by checking the current date and only posting events greater than the event_starting_date which is a datepicker field.
The first section is working code that allows the filtering dropdown:
<?php
$args = array(
'taxonomy' => 'academic_programs',
'show_option_all' => '- Any -',
'show_count' => 0,
'name' => 'academic_programs',
'orderby' => 'name',
'value_field' => 'slug',
'echo' => 0
);
$select = wp_dropdown_categories( $args );
$select = preg_replace("#<select([^>]*)>#", "<select$1> ", $select);
echo $select;
?>
<?php
$args = array(
'taxonomy' => 'event_type',
'show_option_all' => '- Any -',
'show_count' => 0,
'name' => 'event_type',
'orderby' => 'name',
'value_field' => 'slug',
'echo' => 0
);
$select = wp_dropdown_categories( $args );
$select = preg_replace("#<select([^>]*)>#", "<select$1> ", $select);
echo $select;
?>
This is where I believe I have an issue:
<?php
$queried_object = get_queried_object () ;
$today = date('Ymd');
$args = array (
'category_name' => 'events',
'posts_per_page' => 6,
'orderby' => 'meta_value',
'meta_key' => 'event_start_date',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'event_start_date',
'meta-value' => $value,
'value' => $today,
'type' => 'DATE',
'compare' => '>=')),
) ;
$query = new WP_Query ($args) ;
?>
Everything past the orderby argument down to the meta query array is where things seem to break.
This is how I get the query to post. If I leave out the above code block and remove the $query variable, I do get the filter to work, albeit without the necessary sort.
<?php if ( $query->have_posts() ) { while ( $query->have_posts() ) : $query->the_post(); ?>
<span><?php $date = get_field('event_start_date');
$starttime = get_field('event_start_time');
echo $date . " - " . $starttime; ?></span></br>
<?php endwhile; } ?>
Any help would be appreciated.