You can use get_the_time()
to get the date of the current post. Just use a format that only includes the year and date, and compare it to the current date using the current_time()
function with the same format:
if ( get_the_time( 'Yd' ) === current_time( 'Yd' ) ) {
// Post was published today.
}
Related Posts:
- Stop WP from creating “Sample Page” and “Hello World!” post
- How to Create Editable Blocks of Text for the Homepage?
- Count how many posts in category
- Custom Single Post By Category
- Set Post Title to Read-only and Disable Permalink Slug Editor in Gutenberg
- how to get permalink using sql
- Adding Post Counts to Menu (Nav) Programmatically?
- how to display full post with pagination on home page
- Show chart in post using data passed as custom field
- Show One Category on Post
- Show post titles only on the homepage
- how to grab first link in post… and of course call it
- Creating new page with pre-defined parent page
- Get all Youtube video’s from posts and embed them on a different page
- Get all posts by post_author
- Linking to page with all posts
- Send email to user that his post has been rejected
- How can I highlight syntax like it appears on stackoverflow?
- What Defines What Category A Post Picks (if in multiple)
- Add Category name to Post Title (h1)
- Every possible way to get data (posts) from WordPress
- Blogroll – Different layout for first post
- How to delete old posts’ edits to save space?
- When trashing a post, also trash related comments
- Image Insert into posts and pages not working after 3.2.1 update
- Blog Posts not showing title
- Show info to author only
- allow new users to post an article before they sign up [closed]
- Make Post Editor Select Number of Columns To 1 By Default
- Display post category in foreach loop with category link
- Adding the_date inside tags around the_content
- Mixing Tweets with Posts
- How to Link to all posts that have the Standard Post Format
- Problem with permalink routing?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- Whenever an author saves their post a \" is added next to the double quotation marks
- updating a post doesn’t trigger a function
- Hide a specific category in admin All Posts page (WordPress)
- Making a custom Pagination for multi page blog post
- Updating post data on save (save_post vs wp_insert_post_data)
- Lost draft under all posts and drafts
- “edit_published_posts” and “edit_other_post” issue
- WordPress is replacing double minus signs in Post Title, how to disable it?
- When changing pages to posts, how do you set up 301 redirects for the page URLs?
- using is_paged for hiding image on posts
- Notification when visitor is on specific WordPress Article
- WordPress custom post type with folder structure in slug
- wpColorPicker – problem with implementation to post meta
- get posts from Custom Post Type & Category
- How to group only VISIBLE posts? [closed]
- wordpress posts template remove default template from menu
- Does WP automatically tag posts into the archive?
- Show custom post with custom categories with specific slug
- Updating permalink structure using ‘post_link’ filter results in 404 error for posts
- How to set a certain Custom Template to a Single Blog Post
- How to Featured content with images in home page?
- why the posts queried from sql is more than those showed on the page?
- how to display today’s most viewed posts order by custom meta “views”
- Keyboard shortcut for headings on safari
- Highlighting Current Category in the Archive and Feeds page
- Optimal WP Web App Backend for mobile app development
- Change permalinks for posts & for custom post types
- How to customize blog post titles to render a YouTube logo on posts with an embedded video?
- Post page overwrite the custom blog page
- Check if almost 10 year old – working code is up to date
- Post Image Gallery After Content Function messes with other content
- Updating post status via rest api
- Query custom post type custom meta key
- WordPress: Develop multiple posts with different data
- unable to display two post per page in wordpress front-page.php
- WP Ajax returning 0, can’t find action
- Remove pagination if search returns empty
- Scheduled posts appear as clickable in the front end
- Counting Posts by Category
- show image gallery in archives or category page
- Page with Category Returning 1
- Adding wordpress posts using phpmyadmin
- Colorbox not working on native WordPress gallery when gallery is loaded thru AJAX
- Customizing URL slugs of Custom Post Type and Taxonomy make posts/pages 404
- How can I get post text from all posts on a WordPress news site?
- Use special template for the first post in the loop
- Posting a comment redirects admin/users to blank page
- Is it possible to have dynamic post id # in add_menu_page()?
- Expired Post with More Recent Time Stamp?
- Post preview in iframe without saving the post
- Set post beginning date and final date
- Posts don’t appear on Template Page
- How to get only current images of a post
- Latest Posts not in the right order
- Using Post ID and Page ID in same function
- Howto put advertising as post number 1,2,3 etc
- How to Include a common category in a custom Category Search
- limit posts per page
- WordPress Admin Tables in Post View
- How do I insert a custom field in a user submitted post?
- Viewing category won’t show up Custom post type posts
- Print out one of 2 post category [closed]
- How to get if category has posts?
- website images getting corrupt automatically
- Posts Page in WordPress loading bare HTML of my homepage