@rpk Wow, thks for the tip. I did everything to resolve this problem in two of my sites. For some reason the key activation field was empty in production. =)
Having this problem too using a custom folder to plugins :(.
define( ‘WP_PLUGIN_DIR’, dirname( __FILE__ ) . ‘/lib’ );
define( ‘PLUGINDIR’, dirname( __FILE__ ) . ‘/lib’ );
define( ‘WP_PLUGIN_URL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/lib’ );
Solved in 5.0.6
Hi @banjer
I did not know about “REGEXP”, thks for the tip. But I did this with some another workaround.
1 – First I created a simple text field for “ORDER” named “fm_mun_aniversario”
2 – The birthdays is the normal wp post_date field
3 – So I created a function to catch the month/day when save the post and put in the custom field with MMDD format:
function save_mun_meta( $post_id ) {
$slug = 'municipios';
if ( $slug == $_POST['post_type'] ) {
$fm_mun_aniversario = get_the_time('md');
update_post_meta( $post_id, 'fm_mun_aniversario', $fm_mun_aniversario);
}
}
add_action( 'save_post', 'save_mun_meta' );
4 – And the query:
$ordem = date('md');
$meta_query = array(
array(
'key' => 'fm_mun_aniversario',
'value' => $ordem,
'type' => 'NUMERIC',
'compare' => '>='
)
);
$proximos_args = array(
'paged' => $paged,
'post_type' =>'municipios',
'order' => ASC,
'orderby' => 'meta_value_num',
'meta_key' => 'fm_mun_aniversario',
'meta_query' => $meta_query,
'posts_per_page' => 6
);
$proximos_items = new WP_Query( $proximos_args );
if ($proximos_items->have_posts()) :
while ( $proximos_items->have_posts() ) : $proximos_items->the_post();
get_template_part('templates/MunAniversario');
endwhile;
else:
echo "<p class='empty'>empty</p>";
endif;
Worked for me 😀
Hi Elliot.
What if I want do query ALL posts by month JANUARY from years ALL ~ 2014 ?
I’m trying to create a birthday system that return all birthdays by current month or the next 10 birthdays.
I can put the date_query if I use the wordpress post_date but this is not the case. How use the meta_query system for that?
I created a datepicker field with default config.
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.