Try wrapping the rsort
bit in an if statement like this:
if (!empty($post_dates)) {
rsort($post_dates);
} else { echo 'optional error message here'; }
This will check to see if the variable is empty first, and only run rsort()
if it is not empty. This check works most of the time, but a false positive can sometimes occur if, for example, the variable is not actually an array but contains other data! (such as an error message). Alternatively, you may find this to work better in certain circumstances:
if ($post_dates != '') {
rsort($post_dates);
}
This will only continue if the variable does not equal null
, which isn’t quite the same thing as being empty. There are other ways to check if the variable is what you want, for example if (is_array($post_dates)) { do stuff }
.
Related Posts:
- Deprecated: Function get_magic_quotes_gpc() is deprecated in WordPress that causes height change in hoe slider, all Tabs on website
- Warning(unlink) Warning: session_start() Warning: Cannot modify header information
- wp warning declaration compatible [closed]
- Warning on my WordPress site [closed]
- How to resolve Warning: Missing argument 2 for ufwp_widget_text ()
- What’s the warning on line 736?
- Unknown file php5fcgi.core
- Cannot modify header information when I try my site with www
- “Warning: call_user_func_array() [function.call-user-func-array]:” above comments form [closed]
- How can i get rid of warning messages [closed]
- Attempt to read property “ID” on null”
- numpy division with RuntimeWarning: invalid value encountered in double_scalars
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- What does “control reaches end of non-void function” mean?
- libpng warning: iCCP: known incorrect sRGB profile
- warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
- Illegal string offset Warning PHP
- Illegal string offset Warning PHP
- libpng warning: iCCP: known incorrect sRGB profile
- Variable warning set but not used
- Data truncated for column?
- Avoid passing null as the view root (need to resolve layout parameters on the inflated layout’s root element)
- RuntimeWarning: overflow encountered in ubyte_scalars
- Warning: Found conflicts between different versions of the same dependent assembly
- mean, nanmean and warning: Mean of empty slice
- ERROR: Control may reach end of non-void function /
- Warning : overflow in implicit constant conversion
- Remove warning messages in PHP
- Troubleshooting “The type parameter T is hiding the type T” warning
- What does “warning: not all control paths return a value” mean? (C++)
- WP_DEBUG is not set, but I’m still getting warnings
- PHP Warning on fresh install (Connection timed out)
- “Warning: count()” error on php 7.2
- WordPress 4.9.5 PHP intermittent warning trim() expects parameter 1 to be string, array given
- Warning: urlencode() expects parameter 1 to be string, array given
- Stackoverflow type of badge plugin giving warnings in WordPress 3.5
- WordPress Errors in generated by theme check plugin [closed]
- What is causing this error? “Warning: Invalid argument”
- Get WP CLI to hide debug warnings and notices in JSON output, same setting as website
- Warning: array_pop() expects parameter 1 to be array, boolean given
- Undefined property: WP_Query::$post
- Removing warnings and notices from production servers
- Ajax stops working when logged in?
- How to properly setup an activation hook
- How to fix Warning: call_user_func_array()?
- CPT issue: Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Warnings On Updating WordPress
- Change ICL_LANGUAGE_CODE for WPML
- Error: Warning: strpos() in media.php
- Getting notices on fresh 3.6.1 install
- Getting php_network_getaddress error : No such host is known?
- class-wp-hook.php on line 288
- Website Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘Wppr_Public’ does not have a method ‘amp_support’
- Block editors annoying warnings
- Warning message (re. php) on the blog page
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- array_filter warning – wp-includes/post.php line 3148
- Fix Warnings that shouldn’t be necessary to fix
- Weird string offset errors when displaying post attachments
- Warning: spl_autoload() [function.spl-autoload] (Term Menu Order)
- Error while setting role
- How to fix this PHP warning in WP-Admin after upgrading to 3.1.2?
- I have this error notice ‘wp_enqueue_script was called incorrectly’ in my plugin
- class ‘wphpc_PAnD’ not found
- Warnings even when the WP_DEBUG set to false
- locked out of wordpress site ‘warning: require once’
- WordPress function to add text warning on every pages [closed]
- Wp Debug Enabled True Notices and Warning
- PHP Warning: Missing argument 2
- Custom meta box in custom post type not working
- WordPress comments – delimiter “/” not found
- wp_logout_url($redirect) won’t logout and redirect ()
- Can’t save changes or modify settings in Dashboard but Pages and Posts are fine
- Error: Attempt to read property “ID” on null
- How to display a warning when an uploaded image is too small?
- PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
- After updating theme & plugin I am getting an error message
- Admin keeps showing pending translation update
- PHP warning with code for nav menu walker [duplicate]
- PHP Warning adding menu
- Debug in WP backend
- Default and warning messages & no login
- How can I get $wpdb to show MySQL warnings?
- Theme check warning about text domain
- Custom post type – Errors
- A more elegant way to handle notices/warnings
- How do I issue a warning in a wordpress plugin?
- Warning: preg_replace(): Compilation failed: unknown option bit(s) set at offset -1
- First argument is expected to be a valid callback for cp_admin_init and _canonical_charset
- Warning: Cannot modify header information – headers already sent
- Displaying warning if no featured image has been set – Post Editor
- Warning: Cannot modify header information
- My wordpress site wont load, it gives header error warnings
- Marketpress php warning on server, no problem on localhost [closed]
- “Cannot modify header information” warning?
- Warning: Illegal string offset ‘post’ and ‘page’
- Please Help Me, How to Fix PHP Error Undefined Array Key “srcset”
- Trying to add taxonomy terms to search results page
- Core error when calling remove_menu_page