Right now you’re just checking for the post date.
You’ll need to check for ‘post_modified’ aswell. You can find the complete post-object here: https://developer.wordpress.org/reference/functions/get_post/#user-contributed-notes
You can modify the check to look something like this:
if (strtotime($post->post_date) < strtotime('-1 year') && strtorime($post->post_modified) < strtotime('-1 year')){
echo 'Old Post';
} else {
echo 'Not Old Post';
}
That should check for both.
Related Posts:
- How to get year, month and hour in WordPress?
- WordPress returns a wrong date
- Unable to set right time in admin and frontend template
- display month in french in wordpress/php?
- Get date numerical and separate?
- Print last modified date only on posts
- How to get User Time Zone in WordPress?
- Get date function not working
- WordPress wrong dates bug
- Don’t update modified post date when user add a product review or comment?
- How to pull date/time in french format for wordpress post?
- Can’t add to time? [closed]
- Adding a number to a date
- Display Year and Month from custom field + Age Calculator
- Convert custom field date format to “WordPress default”
- Calculate business days
- Handling error states with admin_post
- Archive listing of posts by publish year (multiple years)
- get_the_content if it contains multiple lines it results in SyntaxError
- Insert code when users come from an specific referer
- How to display related posts from parent category
- Make custom field meta not display if there is not data in it
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- Get_the_author doesn’t return author name
- Way to display “Yesterday”, “Today”
- Hide wordpress field if data is empty in post!
- How can I use wp_query to show all product data using just the products ID?
- Trying to add attribute to my posts’ featured image
- Loop through categories and display posts title under each dropdown
- How to store post ID’s in cookie or session to display the same posts later
- Post + form + action + results on the same page
- Post repeating with infinite scroll
- Display related posts without a plugin
- 3 different times on my WordPress website
- Count posts on multisite with blog id
- Making (and edit existing) posts with ID included
- Parsing Menu Items and Blog Posts
- Pagination on Custom Post
- $wpdb returns duplicate posts
- How to show an entire post content and not also the excerpt?
- WordPress query undefined offset in loop
- WP_Query: getting posts where custom field exists
- Increment paged on WP_Query
- get post id from wp_insert_post for get_template_part
- Modify main query before it run without pre_get_post
- .html end of URl affected to SEO?
- Displaying content on posts page based on category
- how to make an array of post id’s in is_single
- Loading Posts & Category with Ajax
- array_rand not working correctly?
- Update if post with specific title exists
- Need help removing […] after excerpt
- WP_Query() load selected post
- Unable to render custom field after attempt to generate a list of recent post in page template
- Why when I create a new post I found 2 record related to this post into the posts database table?
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- understand what code is doing when prepending /blog
- Advanced Query posts
- My worpress search page is showing no results
- My Custom Post Type AJAX Query is Returning no posts – why?
- How to get post image caption by index
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- Is there anyway I can call the year once?
- Check $post->ID against multiple values
- Limit the number of characters/words in an excerpt for a related posts section
- Posts missing on author page
- How to allow users to save list of posts in wordpress?
- WordPress recent post
- Need to show 7 posts from actual date
- Closing Comments conditionally in comments.php
- How to center all text body in single.php at once?
- Primary navigation menu with timed items from custom post type
- Having trouble with customizing blog posts on the home page
- Related Posts: if there is no category use tags
- How do you update post date (year only) in a separate custom field?
- How do if all posts has this category ID then do this
- Get the total Author Favorited posts
- Get current_post in reverse order with pagination
- Getting error in sql query
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- Insert div after every three posts in home.php [duplicate]
- PHP tag in post content makes wordpress go crazy
- Unable to get Post Category Name and URL
- Dynamically Create Posts Via XML File
- Basic PHP question (displaying post title over thumbnail) [closed]
- insert thumbnail image from php script
- Post from front end form to post_meta
- media_handle_sideload() returned post_id being incremented
- Saving Post redirects to 404 page when php $_GET variable in post body
- How can I add WordPress Audio Player as featured audio in Audio Blog Posts?
- Trying to see if page is category or single and displaying title with appropriate heading tag
- How to customize posts in WordPress by using HTML and CSS?
- foreach all the post
- Display Current Time using shortcode
- $post->ID calls for current page, but what is the code to call for any new page created and published in WordPress?
- Blog Posts not sorted and pagination not adjusted after filtering some category
- How to create a WordPress PAGE in another folder?
- How do I get a function to work in single.php
- Count the number of matching post names in foreach loop
- Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)