Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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?

    #799621

    Hey 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-772563

    Best regards,
    Victoria

    #799638

    Hello 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

    #800510

    Hi 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,
    Victoria

    #801471

    I 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?

    #802609

    Hi TimBoySlim,

    Does it log any error or just does not work?

    Best regards,
    Victoria

    #802670

    It just hangs on the preload screen when I reload the page after updating anything. Can’t even get to an error log!

    Tim

    #804128

    Hi,

    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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.