Thanks for the help. Sadly the file hasn’t been generated so am still stuck!
Thanks.
I have updated my code and installed a Cron plugin that will run any cron set but the radio field doesn’t updated to ‘Closed’.
Both the current date and stored custom field date are the same format:
‘Ymd’
Any ideas?
Hi @james
I have placed it into single-job-listings.php file. There is a possibility that I’ll be using a custom template or archive page to display a list of these job listings too.
The trouble seems to be that the backend doesn’t update unless someone views the front-end. So maybe, the only solution is a cron job?
Thanks
I managed to get it to work using this bit of code. Not sure if a cron job would be a much better solution though?
<?php
/*
Check if the job listing has closed (manually or automatically based on date). If so, add text to end of the title and change the label status.
*/
// Setup checks for todays date and datepicker date in backend.
$today = date( 'Ymd' );
$expire = get_field( 'job_listing_closing_date', false, false );
// Change Job Status field in backend to Closed if date has passed.
$status = get_field( 'job_listing_job_status' );
if ( $expire < $today ) :
$status = 'Closed';
update_field( 'job_listing_job_status', $status );
endif;
?>
Was this resolved as I am looking for the same thing.
Thanks
I managed to solve my problem using the answer here:
https://support.advancedcustomfields.com/forums/topic/query-date-picker-by-date-then-time/
$args = array(
'post_type' => 'schedule',
'posts_per_page' => '-1',
'meta_query' => array(
'relation' => 'AND',
'date_clause' => array(
'key' => 'schedule_time_slot_%_schedule_show_date',
'compare' => '=',
'value' => $tue,
),
'time_clause' => array(
'key' => 'schedule_time_slot_%_schedule_show_start_time',
'compare' => 'EXISTS',
),
),
'orderby' => array(
'date_clause' => 'ASC',
'time_clause' => 'ASC',
)
);
This helped me resolve my needs too. Thank you so much.
I think I’ve got a solution and will post my findings here if I do!
Two fields: Date (datepicker) and start time (time picker). Sort by date and then orderby date and time.
Thanks for the help.
Sorry @acf-support / James, it’s working fine actually. Apologies.
One thing I have noticed though and maybe good for another thread actually. But I also need to order the posts returned in time order. I have a custom field (within the same repeater) called ‘start_time’ and the posts need to be ordered by that… Any ideas how I modify my WP_Query for that?
<?php
$args = array(
'posts_per_page' => -1,
'post_type' => 'schedule',
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'schedule_time_slot_%_schedule_date',
'meta_query' => array(
array(
'key' => 'schedule_time_slot_%_schedule_date',
'compare' => '=',
'value' => $mon,
'type' => 'DATE',
)
)
);
?>
Your help is much appreciated.
James; one thing I have just noticed though is that, if I set the date of the show to the Monday just passed and the Monday coming, both dates echo out.
(As this example show may be ‘on air’ every Monday of every week)
How would I edit my code so that it only displays the show for the Monday of ‘this week‘?
// Get dates for the week, starting on a monday
$monday = strtotime('last monday', strtotime('tomorrow'));
$tuesday = strtotime('+1 days', $monday);
$wednesday = strtotime('+2 days', $monday);
$thursday = strtotime('+3 days', $monday);
$friday = strtotime('+4 days', $monday);
$saturday = strtotime('+5 days', $monday);
$sunday = strtotime('+6 days', $monday);
$mon = date( 'Ymd', $monday );
etc...
<?php
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'schedule_time_slot_%", "meta_key LIKE 'schedule_time_slot_%", $where);
return $where;
}
add_filter( 'posts_where', 'my_posts_where' );
?>
<?php
$args = array(
'posts_per_page' => -1,
'post_type' => 'schedule',
'meta_key' => 'schedule_time_slot_%_schedule_date',
'meta_query' => array(
array(
'key' => 'schedule_time_slot_%_schedule_date',
'compare' => '=',
'value' => $mon,
'type' => 'DATE',
)
)
);
?>
Many thanks
I am using ACF PRO V5.3.9.
Within the date picker field though, the Return Format is set to d-m-Y.
Also, when echoing out the sub_field within the repeater loop, the date outputs as d-m-Y.
I have now converted my $mon variable to the format suggested, Ymd, and it works. Awesome.
So mental note made: always use Ymd (yyyymmdd) as my base date formats!
Thanks very much James.
This worked for me. Thank you
I’v tried adding this to the head of my template file (and also in functions.php) but still no title is created?
function my_pre_save_post( $post_id ) {
/*var_dump( $post_id ); // OUTPUT: NULL
var_dump( $_POST['post_id'] ); // OUTPUT: string(3) "new"
die();*/
if ( $post_id != 'new_post' ) {
return $post_id;
}
$post = array(
'post_title' => 'A custom title',
);
$post_id = wp_insert_post( $post );
return $post_id;
}
add_filter( 'acf/pre_save_post', 'my_pre_save_post', 10, 1 );
Any other ideas?
Thanks for the help.
Did you resolve this as I’m trying to do the same.
Thanks
Hi
Using your add-on @shawnp_thinkodin, good work. Question is; how can I map a new user to those custom fields in User Profile?
And, will there be a way to have a dropdown for the Country field?
Turns out it was the actual META data in the clients’ PDF’s.
Did you manage to get the Front End feature setup?
I am currently looking for a solution that users can fill out the front end form, which will ask for payment via PayPal and then create a post (custom post type).
Do you think you’re plugin will help with the PayPal side of things?
Did you ever get this sorted; am looking at the same thing. I want to use ACF instead of GF if possible.
Thanks
Thanks Darren. Worked for me too 🙂
Solved:
// create marker
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: 'DSRU',
icon: 'http://www.example.com/application/static/images/gmap-marker.png'
});
Thanks John.
Hopefully it’s something that can be implemented as it’s a bit odd to have the Archives listed by default when I don’t want my client to be able to choose them. They have no need in this particular instance.
Many thanks.
Also; would this be possible to display the fields on Bulk Edit screens?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.