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
- How do I create a single.php file as the default template for single posts in the twentytwentythree theme?
- Date not working correctly
- trouble with page_id & highlighting current page
- Convert the_permalink() function output into string
- Making my first wordpress template
- How to use array in function to get only value I want
- Apply class to every third list item? [duplicate]
- Only show image from custom field when present
- Cinema site, retrive the movies that actor play in
- How to include custom code on a page that’s set to act as homepage?
- retain querystring values when savincustom options in admin
- PHP if statement works in template files, but not header
- How Can I Edit the Registration Code?
- Error while setting role
- Editing a PHP file to include a small text piece on every page
- Get categories names as an array to use it in theme settings
- Should i use the wordpress Options table or to create database table..?
- variable value disappears in a second loop
- Force Users To Relogin
- unknown issue in ‘header.php’ preventing theme from displaying fully
- Hide a div to subscribers(user role) in one page (is_page)
- Security updates to 3.3.2
- Where is this function’s callback getting its arguments from?
- How can I use a sliced image As banner? [closed]
- persist a variable set in header.php all the way down to footer.php
- Echo title attribute php
- Can a page contain php code?
- Last class on last headline?
- Unable to Find Space in Custom Function
- Is it possible to display a DIV to not logged in users and then change it for users who are logged in?
- Strip Paragraph Tag
- Unable to process php via shortcode
- working with term_relationships table
- Creating a blog on my companies new website using WordPress but I have sidebar issues
- Creating a mobile site by adding a new class to the body tag from functions.php
- WordPress plug-in for dynamic download link?
- Using WP functions such as the_title() in an included php file
- GET problem in WordPress
- WordPress gallery shortag
- Almost Done… Post Format Code
- wordpress admin plugin menu custom css
- Help with page nav?
- Show recent posts starting at a specific number archive
- Add title=”” to A PHP Code