Click here to Skip to main content
15,560,542 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all "Want to do it without plugin"

Firstly how can I create a custom field in my custom post type where I can get the date // Our custom post type function function create_posttype() {

register_post_type( '', // CPT Options array( 'labels' => array( 'name' => __( 'Archive' ), ), 'public' => true, 'has_archive' => true, 'rewrite' => array('slug' => 'Archive'), 'show_in_rest' => true,

); } // Hooking up our function to theme setup add_action( 'init', 'create_posttype' );

I want to fetch the posts which has date in "Custom post" before the current date. Example -> If in the custom field I entered 2021-12-25 and it's before the current date then the post should be fetched and after the current date crossed 2021-12-25 post should not be fetched.

What I have tried:

tried using Suppots while registering the custom post type but it takes a simple value not the date and also tried using meta_query to fetch the results

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900