Ok, so I finally figured it out. It turns out I was over complicating it as usual. I will post my solution in case it helps others. I was trying to put together a complicated compare loop where I compare a post object field that sits in a repeater from another post type with the title of the current post and then loop if they matched.
Anyway, here is what I ended up with:
<?php
$post_id = get_the_title();
$wp_query = new WP_Query();
$wp_query->query( array (
'post_type' => 'case',
));
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php while ( have_rows('shift_details') ) : the_row(); ?>
<?php $post_object = get_sub_field('nurse'); if( $post_object ) : $post = $post_object; setup_postdata($post); ?>
<?php $nurse_title = get_the_title(); ?>
<?php if ($nurse_title == $post_id) { ?>
<?php wp_reset_postdata(); ?>
So, I am actually just querying the post type and then looping through all repeater rows but then adding a check to see if they match after and continuing the loop if they do. I hope this makes sense and helps someone else out there.
Gentle Bump. Please help with this one. My client wants to launch ASAP and this is the only thing in the way. This community has helped me alot and I have bought the plugin twice to show support since I can not contribute much code.
Thank you all for looking!
This post has been so helpful and I really appreciate you posting this. I am wondering if someone could help just a bit. I am using the example from @mkeys and it is working. However in my use case I need the form to create the custom post type post as well as creating a new user. Can this function be altered to do both at the same time or do I need to create a generate post function for the same form and then add each field individually?
Thank you for looking and please help!
Thank you, That did it. Your help is very much appreciated.
Gentle Bump, Please Help!
I have found the solution to this on my own. It turns out that the scripts for datatables was not loading on certain pages for some reason. I was able to fix this by adding them directly to the template file. Not the best option but it works for now and is certainly not an ACF issue so I will say this is resolved. Thanks for looking!
This is great and I know I am so close but should this be working for the datetimepicker field?
I have implemented what you suggested and it looks great but I am still not getting it right. I am pretty sure that it is because I am using the ‘Date Time Picker’ field and not the ‘Date Picker’.
Can you suggest the change I need? Thank you very much for your time and help!
I know this is an old post but it is exactly what I need to do. I am using a date and time picker field for both start and end of an event. I need to make it so that the end date and time can only be after the start date and time. I have googled for hours trying to find a solution but this one is as close as i have gotten. What i could really use is an elaboration on your suggestion.
I am currently using a repeater field with start and end fields. What else would you need to assist me in this, or can you recommend a place for me to look. Thank you so much for helping me out.
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.