Troubleshooting //
Unable to Display Date Field in the Admin Filters Properly

Unable to Display Date Field in the Admin Filters Properly

Question

I have created a date field admin filter, but the data isn’t displayed right. How to show the correct date in the admin filters?

Answer

While adding a date timestamp field in the Admin Filter, you cannot get what you expect. Instead of the date added to the post, you will get another result.

Firstly, let’s check what values should be represented during the Admin Filter creation.

date admin filter

Fill in the fields and mind to select the needed meta field. Update the post type once done.

Now the created options in the data filter will not look as you have typed them in. To fix this problem, use the PHP code

Head to the Appearance > Theme Editor. Open the functions.php tab and scroll down till the end of the code. Paste the required PHP code.

NOTE. Paste the Meta Field Key related to the meta field you have used while creating the Admin Filter.

For instance, we have created the Admin Filter based on the Date Timestamp meta field.

We have put the following meta field key during the meta field adding.

date timestamp meta field

The final result will look like in the picture below. Put the Meta Field Key into the highlighted segment instead of the ‘__date’ example.

functions php code

Once done, click on the “Update File” button. Head to the CPT where the Date Admin Filter is added. 

Open the filter and check if everything works fine.

properties cpt date filter

Now you know how to display the correct date options in the admin select filter.

Was this article helpful?
YesNo
Still need help?
Submit a request