Accessing custom URL parameters

Global declaration for the variable was missing in the page. After adding the following declaration, code works as expected.

global $wp_query;

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