-
AuthorPosts
-
May 23, 2017 at 3:29 pm #798320
Hi
I’m using ACF plugin to add a ‘event_date’ custom field to posts. I am using categories (Music, Theatre, etc) to display posts for each in a grid layout. However, I can’t seem to get the grid to display the full category archive in date order (by the custom field).I’m using this function in the child theme functions:
add_filter(‘avia_post_slide_query’,’avia_order_by_date’, 10, 2);
function avia_order_by_date($query, $params)
{
$query[‘orderby’] = ‘date’;
$query[‘meta_key’] = ‘event_date’;
$query[‘meta_type’] = ‘DATE’;
$query[‘order’] = ‘ASC’;
return $query;
}
wp_reset_postdata();Can you help please?
May 25, 2017 at 3:57 pm #799621Hey Tim,
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Can you confirm that the fields are added?
https://kriesi.at/support/topic/cpt-and-acf/#post-772563Best regards,
VictoriaMay 25, 2017 at 4:32 pm #799638Hello Victoria
Yes I have ACF plugin activated and the custom field ‘event_date’ active in the loop-index.php file in the child theme.The query appears to be ordering the posts by the first two digits only (see ‘Music’) and not date order. So 31 May comes after 30 June. This would suggest that only ‘ASC’ is working and the ‘date’ query isn’t, but I can’t figure out what I’m doing wrong.
Thanks for your help
May 27, 2017 at 11:16 am #800510Hi TimBoySlim,
The issue here could be with the way these dates are stored in database. Looks like it only takes into account the day, not the month when sorting. You need to check how they are stored.
Best regards,
VictoriaMay 30, 2017 at 12:46 pm #801471I have added the following code to postslider.php (child) :
$date = get_field(‘event_date’ , $entry–>ID);
$date = new DateTime($date);
$output .= “<div class=’custom-details’>” . $date–>format(‘jS F Y’) . “</div>”;It seems to work until I add a new post or update an existing one, then it just hangs.
Can anyone help please?
June 1, 2017 at 3:46 pm #802609Hi TimBoySlim,
Does it log any error or just does not work?
Best regards,
VictoriaJune 1, 2017 at 5:27 pm #802670It just hangs on the preload screen when I reload the page after updating anything. Can’t even get to an error log!
Tim
June 5, 2017 at 8:37 pm #804128Hi,
Those are prety advanced modifications and you should have a child theme in place to do them.
We suggest, to get further assistance and help to please consider hire a freelancer to help you out.Thank you
Best regards,
Basilis -
AuthorPosts
- You must be logged in to reply to this topic.