Skip to content

Instantly share code, notes, and snippets.

@mikeyarce
Created April 8, 2015 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeyarce/91fa7536193a7c8645f9 to your computer and use it in GitHub Desktop.
Save mikeyarce/91fa7536193a7c8645f9 to your computer and use it in GitHub Desktop.
add content to top of sidebar in Jetpack mobile theme
function jetpackme_is_mobile() {
// Are Jetpack Mobile functions available?
if ( ! function_exists( 'jetpack_is_mobile' ) )
return false;
// Is Mobile theme showing?
if ( isset( $_COOKIE['akm_mobile'] ) && $_COOKIE['akm_mobile'] == 'false' )
return false;
return jetpack_is_mobile();
}
function jetpackme_maybe_add_action() {
// On mobile, and on the home page?
if ( jetpackme_is_mobile() ) {
add_action( 'get_sidebar', 'add_before_my_siderbar' );
}
}
add_action( 'wp_head', 'jetpackme_maybe_add_action' );
function add_before_my_siderbar( $name ) {
echo "Loaded on top of the {$name}-sidebar";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment