The problem is that your date format is not a standard format that strtotime()
understands. Instead just use get_the_date()
with the format set to 'U'
, which returns the timestamp, and compare that to strtotime( '-1 year' )
:
if ( get_the_date( 'U' ) < strtotime( '-1 year' ) ) {
}
Related Posts:
- How to get WordPress Time Zone setting?
- Converting timestamps to local time with date_l18n()
- PHP function showing wrong time in WordPress
- Custom SQL query to get List of posts with featured image url
- How to get year, month and hour in WordPress?
- the_post_thumbnail() based on the Post ID
- Why does this echo values in the wrong order?
- WordPress returns a wrong date
- How to check for WordPress timezone type?
- Insert After Second Paragraph Without Tag?
- if post id matches these id’s then do this
- Unable to set right time in admin and frontend template
- Get_the_author doesn’t return author name
- Convert a date to ISO8601 date format
- wrong php date()?
- Link for Most Recent Post
- display month in french in wordpress/php?
- Displaying the Month and Year that a page was Created?
- Get date numerical and separate?
- Using loop pagination on single.php
- Print last modified date only on posts
- Find hours between post_date and post_date_gmt
- 3 different times on my WordPress website
- single.php with different look by category
- How to get User Time Zone in WordPress?
- How do I check or test a WordPress Auto Year Change Script?
- How to present a div only when the index.php is accessed for/by the single post pages
- Shortcode function doesnt work without caption
- how to make an array of post id’s in is_single
- Comparing Dates from custom field
- Get date function not working
- PHP time function ($today) for GMT +1
- Pagination in single.php
- Hide publish date when update date
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- How to detect and handle the time difference between server and user in WordPress?
- No more get_option(‘date_time’) in WordPress 5.5?
- WordPress wrong dates bug
- Limit the number of characters/words in an excerpt for a related posts section
- My single.php page skips the first div tag
- How to center all text body in single.php at once?
- How to pull date/time in french format for wordpress post?
- Can’t add to time? [closed]
- LinkedIn Share Post Button
- Ordering / grouping posts by datepicker ACF
- Array sorting assistance
- Adding a number to a date
- Display Year and Month from custom field + Age Calculator
- Post Thumbnail on Single (if elseif else)
- Can i show items based on the day with php?
- Custom single.php files for different post formats
- Display Current Time using shortcode
- How do I convert a custom field to a php date format? [closed]
- Change date/time format in custom plugin
- Convert custom field date format to “WordPress default”
- Shortcode Displays 2 times
- Allow Editors to edit pending posts but not draft ones
- Check php version before theme activation
- PHP calling AJAX function that relies on passed PHP function values not working
- I think emoji are killing my WordPress site… How can I debug?
- WordPress Ajax Data problem
- Remove all nav menu classes ( but keep useful ones… )
- Hiding a php element from mobile browsers
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- PHP variable = get_the_post_thumbnail_url outputting without slashes
- Automatically adding new post categories to menu
- WordPress every page is 404 not found including admin resources
- How to show a users bio on a page
- Add Ajax Hooks and Call from Custom Template PHP
- Display all pages – in order
- Backend of the WordPress.com [closed]
- Get Page ID from Backend
- PHP in Edit Post link
- How set a custom URL for a new theme file in WP?
- How to get post ID from button and pass title to Modal
- file_get_contents(includes_url( ‘/js/jquery/jquery.js’ )); not working
- what is the method to echo class attribute inside the i tag? [closed]
- PHP Warning: include(): Unable to allocate memory for pool
- Can’t change website Title on wordpress
- Query for user roles
- Php file that doesn’t recognize wordpress functions
- Set cookie for visitor
- Is there a way to create a “copy post” link?
- Use of antispambot with $curauth->email
- Add a suffix to the image in the_content()
- add role on WordPress in PHP on a second database
- Enqueue assets from multiple directories using add_action/do_action
- Changing Date Format on Custom Meta Data w/shortcode call
- How to redirect (301) trashed post to it’s parent taxonomy TERM ARCHIVE instead of 404 page
- style.min.css code issue
- How to detect and make links nofollow in author description
- Change taxonomy for categories
- Accessing Variables Used In a Plugin Using PHPStorm + XDebug
- Display wordpress post to static website in the footer
- How to echo a different field if another field is empty?
- Remove the_content From Loop
- My title is showing after the shortcode
- Display Sale Price Before Regular Price (WooCommerce)
- Load a Header in wordpress
- Using is home to get content [closed]