PHP Notice: Function is_page was called incorrectly. Conditional query tags do n
-
I need to load a Google Optimize script in the head of the home page of the main site in a MU network setup. We have code:
// Load Google Optimize script in head function us_homepage_optimize_test() { $site_id = get_current_blog_id(); if(is_page(10) && is_main_site($site_id)) { wp_enqueue_script( 'us_homepage_optimize_test', 'https://www.googleoptimize.com/optimize.js?id=OPT-XXXXXXXX', array(), '1.0.0', false ); } } add_action('wp_enqueue_scripts', 'us_homepage_optimize_test');
The Google Optimize script does not load and in debug.log I see:
PHP Notice: Function is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information.
How should I adjust my functions.php code, please?
Help appreciated.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘PHP Notice: Function is_page was called incorrectly. Conditional query tags do n’ is closed to new replies.