Support

Account

Home Forums Backend Issues (wp-admin) How can I add the post date to Post Object select and display? Reply To: How can I add the post date to Post Object select and display?

  • Thanks, actually, I figured it out; I had to use $post->ID, as $post_id gave me the same date for all posts.

    And I used a different concatenation method to put the date first:

    function add_post_object_date( $title, $post, $field, $post_id ) {
    	$post_date = get_the_date( 'j F Y - ',$post->ID);
    	$date_title = "$post_date $title";
    return $date_title;
    }
    add_filter('acf/fields/post_object/result', 'add_post_object_date', 10, 4);

    And FYI for anyone else reading, this sorts the post objects by date in the backend:

    add_filter( 'acf/fields/post_object/query', 'change_posts_order' );
    function change_posts_order( $args ) {
    	$args['orderby'] = 'date';
    	$args['order'] = 'DESC';
    	return $args;