Help Center
Unable to Display Date Field in the Admin Filters Properly

Unable to Display Date Field in the Admin Filters Properly

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?

Modified on: Wed, 24 Jan, 2024

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

Need help?

Ask Facebook community

Get answers from 22K Crocoblock Community experts from all over the world.

Start a live chat

Ask question to support agent and share its details via chat messages.