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.
Thanks Elliot, that did the trick!
Hi Elliot,
I’m talking about the front end of the website. It shows the date formats in English, but my WordPress installation is in Dutch.
I use the standard jQuery datepicker function from ACF but not the add-on. Which one should I use, or doesn’t that make any difference?
Thanks!
Hi Elliot,
So I have to output it like so?
<?php echo get_sub_field('adres_lid', $row->meta_value); ?>
Because that returns empty.
Sorry to bother you with so many questions.
Hi Elliot,
It seems the data doesn’t already exist inside $row.
This is the output ;
stdClass Object
(
[meta_id] => 1301
[post_id] => 144
[meta_key] => leden_details_0_plaats_lid
[meta_value] => gytsjerk
)
What is the best solutions to output the subfield in the $wpdb->get_results
loop?
Hope to hear from you,
Thanks!
Hi Elliot,
Thanks for your response.
I’ve tried it like this ;
<?php echo get_sub_field('adres_lid', $row->post_id); ?>
But it returns empty. Or isn’t it possible to show a subfield like that?
This is the whole code now
<?php
// get all rows from the postmeta table where the sub_field (type) equals 'type_3'
// - http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results
$rows = $wpdb->get_results($wpdb->prepare(
"
SELECT *
FROM wp_postmeta
WHERE meta_key LIKE %s
AND meta_value = %s
",
'leden_details_%_plaats_lid', // meta_name: $ParentName_$RowNumber_$ChildName
'gytsjerk' // meta_value: 'type_3' for example
));
// loop through the results
if( $rows )
{
foreach( $rows as $row )
{
?>
<li class="leden-details"><?php echo get_the_title( $row->post_id ); ?></li>
<li class="leden-show"><?php echo get_sub_field('adres_lid', $row->post_id); ?></li>
<?php
}
}
?>
Thanks
I have another question regarding this topic.
I’ve managed to get it working with the help of your documentation. It shows the post title of my entries.
But how do I show a custom field within the same loop?
This <?php echo get_the_title( $row->post_id ); ?>
shows the title, but how do I show a custom field?
Thanks, tweaked it a bit and it worked. Thanks for your help!
Thanks, that worked like a charm!
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.