Tell us what you are trying to do? I have custom post type with custom field - happy birthday.
I need sort them by month, for example by "April" and it show me all people who have birthday in april in ascending order by day
Is there a similar example that we can see?
1 april 1973
3 april 1985
15 april 1965
17 april 1978
25 april 2001
29 april 1999
30 april 1996
What is the link to your site? enlace oculto
Ideally I need a list of people with their birthdays for a specified month, for example April or June. If it was possible to select a month and filter all people, that would be great.
Sorted by: April
1 april 1973 King Martin
3 april 1985 Coleman Rhys
15 april 1965 King Vernon
17 april 1978 Wilson Mario
25 april 2001 Garcia Anderson
29 april 1999 Gonzalez Brentley
30 april 1996 Foster Amir
Thank you fro help. Can the birthday day go to data order?
Green Xuan == 02.04.1987
Foster Amir == 03.04.1986
Garcia Anderson == 05.04.1978
King Vernon == 06.04.1994
Gonzalez Ishaan == 11.04.1975
Gonzalez Brentley == 13.04.1981
King Martin == 17.04.1987
Diaz Case == 18.04.1974
Wilson Mario == 20.04.1988
Nelson Woodrow == 28.04.2001
Edwards Nathaniel == 30.04.2001
I've added the following filter hook to "Custom Code" section offered by Toolset with the code snippet namely "filter-for-birthday-in-month":
=> enlace oculto
add_filter( 'wpv_filter_query_post_process', 'func_filter_parent_none_post', 10, 3 );
function func_filter_parent_none_post( $query, $view_settings, $view_id ) {
if ( $view_id ==2220 and !empty( $query->posts ) ) {
$all_posts = $query->posts;
$target_field = 'wpcf-happy-birthday';
$result = array();
foreach($all_posts as $k=>$v):
$this_date = get_post_meta($v->ID,$target_field,true);
$this_day = date("d",$this_date);
$result[$v->ID] = $this_day;
$posts_array[$v->ID] = $v;
endforeach;
asort($result);
$all_posts = array_keys($result);
$final_result = array();
foreach($all_posts as $k=>$v):
if(array_key_exists($v,$posts_array)){
$final_result[] = $posts_array[$v];
}
endforeach;
$query->posts = $final_result;
$query->found_posts = count($final_result); // modify the count of found posts
$query->post_count = count($final_result); // modify the count of displayed posts
}
return $query;
}
Thank you very much for your help, really save me a lot of time to sort people. I will read such documentation and advance my level of knowledge toolset