// ATT: keep Astra's hidden "Skip to content" link out of Google's search snippets (adds data-nosnippet). Front end only. Turn off to undo. add_action( 'astra_body_top', function () { if ( is_admin() || wp_doing_ajax() || isset( $_GET['elementor-preview'] ) || ! empty( $GLOBALS['att_skip_ob_level'] ) ) { return; } ob_start( function ( $html ) { $pos = strpos( $html, 'class="skip-link' ); if ( false === $pos ) { return $html; } return substr_replace( $html, 'data-nosnippet class="skip-link', $pos, strlen( 'class="skip-link' ) ); } ); $GLOBALS['att_skip_ob_level'] = ob_get_level(); }, 0 ); add_action( 'astra_header_before', function () { // Close only our own buffer, and only if it is still the innermost one. if ( ! empty( $GLOBALS['att_skip_ob_level'] ) && ob_get_level() === $GLOBALS['att_skip_ob_level'] ) { ob_end_flush(); $GLOBALS['att_skip_ob_level'] = 0; } }, 0 );
Skip to content