Bug: Banner not showing on pages where get_the_ID not available
-
Hi,
In simple-banner.php line 56 there is the following code:
$banner_is_disabled = in_array(get_the_ID(), explode(",", get_option('disabled_pages_array'))) || get_option('hide_simple_banner') == "yes"; if ($banner_is_disabled){ echo '<style type="text/css" media="screen">.simple-banner{display:none;}</style>'; }On pages where get_the_ID() is not available, such as custom taxonomy archives,
$banner_is_disabledis true whenget_option('disabled_pages_array')is an empty string.a short term fix is:
$disabled_pages = get_option('disabled_pages_array'); $disabled_on_current_page = ! empty($disabled_pages) && in_array(get_the_ID(), explode(',', $disabled_pages)); $banner_is_disabled = $disabled_on_current_page || get_option('hide_simple_banner') == "yes";but I think a better solution would be one that checks what page the user is on and handles it.
For anyone experiencing this issue who needs a fix immediately you can add the following to the functions.php of your child theme:
add_action('wp_head', 'force_simple_banner_display'); function force_simple_banner_display() { echo '<style>.simple-banner { display: block !important; }</style>'; }
The topic ‘Bug: Banner not showing on pages where get_the_ID not available’ is closed to new replies.