Using global $post v/s $GLOBALS[‘post’]

There is no difference when you are using just echo. What works different is unset(): function test_unset_1() { global $post; unset( $post ); } function test_unset_2() { unset( $GLOBALS[‘post’] ); } test_unset_1(); echo $GLOBALS[‘post’]->ID; // will work test_unset_2(); echo $GLOBALS[‘post’]->ID; // will fail The reason is that unset() destroys just the local reference in the … Read more

Avoiding “Usage of a direct database call is discouraged”

Using $wpdb->insert and or related methods to modify data within any of the default WordPress tables, be it posts, postmeta, user, usermeta etc is discouraged because there are functions which already exist for the purpose of modififying data within those tables. For example, wp_insert_post wp_update_post wp_delete_post Database Queries Avoid touching the database directly. If there … Read more

How should I document function calls?

You don’t document function calls, but function definitions. Because the function could be called unlimited times, right? So it makes no sense to document functions when they are called. If you document the call, then probably because you do some things you want to remember later – or let other following developers know. But normally, … Read more

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