Extracting a variable from a permalink

You can get the queried author in author.php with get_queried_object(): $author = get_queried_object(); echo $author->ID; $author_data = get_object_vars( $author->data ); echo $author_data[‘display_name’]; echo $author_data[‘user_url’]; echo $author_data[‘user_email’];

How to access a variable on all page?

Generally, you cannot access local variables in a function from outside the function, so this… function func() { $var = 2; } $var = 1; func(); echo $var; would result in “1”. To make a global variable, you can do this to make $option available outside functions.php: function func() { global $option; $option = get_option( … Read more

No access to global variables?

To answer your question directly, yes, $wpdb is “auto loaded and set up to global by WordPress” but by loading wp-content/themes/roots/script.php directly you are skipping over the WordPress boot process and loading the file exactly as if WordPress did not exist. That is why the normal WordPress objects and constants aren’t available. They haven’t been … Read more

Cron Job variable not accessible

First of all, it’s best not to include wp-blog-header.php. Instead, set the cron job to your homepage URL with a ?mycustomcron=true variable appended (eg: http://example.com/?mycustomcron=true. Then we will check for the existance of this variable when the page loads: function wpse_103127_check_cron() { if ( isset( $_GET[‘mycustomcron’] ) ) { // things to do on cron … Read more

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