Need to show 7 posts from actual date

Try this static function loop_args($parent_id, $number) { $today = getdate(); $args = [ ‘cat’ => $parent_id, ‘showposts’ => ‘7’, ‘orderby’ => ‘ID’, ‘order’ => ‘asc’, ‘date_query’ => array( array( ‘year’ => $today[“year”], ‘month’ => $today[“mon”], ‘day’ => $today[“mday”], ), ), ]; return $args; }

Tag for custom post type

Use taxonomies parameter when registering custom post type: register_post_type( ‘car’, [ ‘labels’ => [ /* … */ ], ‘public’ => true, ‘taxonomies’ => [ ‘post_tag’, ‘categorycar’ ], ] ); Or, after registering post types, use register_taxonomy_for_object_type() function. register_post_type( ‘animal’, /* … */ ); register_post_type( ‘science’, /* … */ ); register_taxonomy_for_object_type( ‘post_tag’, ‘animal’ ); register_taxonomy_for_object_type( ‘post_tag’, … Read more

How can get the last post date of the user?

In your sample code the $latest_posts is an instance of WP_Query class. If you want to get the latest post’s date, you should do this: $latest_posts = new WP_Query( $args ); $last_date=””; if ( $latest_posts->have_posts() ) { $latest_posts->the_post(); $last_date = get_the_date(); } return $last_date;