Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
John

Using Pods Date Field Giving Strange Results

Hi, I am using a PODS date field and I have bought admin columns pro after reading https://www.admincolumns.com/documentation/compatible-plugins/pods/

Use Pods to easily create content types and fields. Working together with the Pods team, we have made sure Admin Columns and Pods are compatible.

My problem is that I have a PODS field of type date. I use that as a column in Admin Columns.

I set the:
Field Type as Date
Date format – doesn’t seem to have any effect on the display tried YYYY-MM-DD and blank.
I have enable filtering, sorting and editing. I am in Australia.

What it looks like…..What it should look like
04/04/2015………….04/04/2015
04/11/2015………….11/04/2015
04/12/2015………….12/04/2015
30/04/2015………….28/03/2015
30/04/2015………….29/03/2015
30/04/2015………….27/03/2015

When I click on the quick edit the correct date appears.
Today is the 30/04/2015 and any date that the day is greater than 12 appears as todays date in the list.

The correct date must be available, as it appears in the quick edit.

Can you please rectify this problem? This is the field I bought this product for.

6 years, 4 months ago
John

Sorry wrote this one because I couldn’t find my old one and between starting it and finishing it received an answer.

6 years, 4 months ago
John

Update, thanks Tobias. This problem is being worked on by the wonderful staff at admin columns pro.

6 years, 4 months ago
Tobias
Developer

Hi John,

A got a temporary fix for you. Just add the following code to your theme’s functions.php and the Pods date should display and sort correctly.


function myplugin_pods_date_display_value( $value, $id, $column ) {
	if ( 'column-meta' == $column->get_type() && 'date' == $column->get_field_type() && $value ) {
		$value = $column->get_date( $column->get_raw_value( $id ), $column->options->date_format );
	}
	return $value;
}
add_filter( 'cac/column/meta/value', 'myplugin_pods_date_display_value', 11, 3 );

function myplugin_pods_date_raw_value( $raw_value, $id, $field_key, $column ) {
	if ( 'column-meta' == $column->get_type() && 'date' == $column->get_field_type() && $raw_value ) {
		global $wpdb;
		$raw_value = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = %d", $field_key, $id ) );
	}
	return $raw_value;
}
add_filter( 'cac/column/meta/raw_value', 'myplugin_pods_date_raw_value', 10, 4 );

The date format you selected isn’t supported by strtotime(), which caused the issue.

This will need be fixed by the Pods team in their code. I made a github issue which I will inform them about.

Tobias

6 years, 4 months ago

You must be logged in to reply to this topic.