Error “Trying to get property of non-object” with Custom Walker for wp_nav_menu

I get this error when there are no menus defined or no menus set for the location at Appearance->Menus. When that occurs wp_nav_menu uses a page walker fallback. The fallback (default) for wp_nav_menu is wp_walker_page which uses wp_page_menu which uses wp_list_pages which uses walk_page_tree which uses Walker_Page not Walker_Nav_Menu. And apparently the two walkers are … Read more

What are the best practices for updating?

Do not just upgrade immediately. Take the time you need for an informed decision. And make a backup, of course. 🙂 Read the changelog for the new version. Example for 3.4.1. The blog announcements and the Codex pages are not complete. Test the upgrade with an exact copy of your production site, including plugins and … Read more

Detecting errors generated by $wpdb->get_results()

There is a class variable that stores the last error string – $wpdb->last_error. By the looks of the way $wpdb is coded, if the query succeeds, $wpdb->last_error will be an empty string, if it fails, it will be the error string returned by MySQL. So something like this would do the trick. $result = $wpdb->get_results(“SELECT … Read more

Get error messages when $wpdb->insert() returns false?

$wpdb->insert() method returns false if the row could not be inserted. Otherwise, it returns the number of affected rows (which will always be 1). You can turn error echoing on and off with the show_errors and hide_errors, respectively. <?php $wpdb->show_errors(); ?> <?php $wpdb->hide_errors(); ?> You can also print the error (if any) generated by the … Read more

No Error Log File, no debug info

Insert this into your wp-config.php // Enable WP_DEBUG mode define(‘WP_DEBUG’, true); // Enable Debug logging to the /wp-content/debug.log file define(‘WP_DEBUG_LOG’, true); // Disable display of errors and warnings define(‘WP_DEBUG_DISPLAY’, false); @ini_set(‘display_errors’,0); Before /* That’s all, stop editing! Happy blogging. */

How to disable the fatal error (WSOD) protection?

We can modify the bool output of the wp_is_fatal_error_handler_enabled() function in two ways: Constant Set the WP_DISABLE_FATAL_ERROR_HANDLER constant to true within the wp-config.php file: /** * Disable the fatal error handler. */ const WP_DISABLE_FATAL_ERROR_HANDLER = true; or define( ‘WP_DISABLE_FATAL_ERROR_HANDLER’, true ); Filter Use wp_fatal_error_handler_enabled bool filter: /** * Disable the fatal error handler. */ add_filter( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)