I’ve stuck a static width content slider on my WordPress sites front page. I’m using the Twenty Eleven theme with a small piece of code included into index.php to display the slider. Unfortunately because of how the theme handles mobile browsers, it causes the slider to push across the screen without the rest of the theme following it. So I was wondering if there was a way to hide the slider from mobile browsers?
The code inserted into the theme is as follows:
<?php if (function_exists('rps_show')) echo rps_show(); ?>
And in context:
<?php
get_header(); ?>
<p><h1 style="font-size:200%">Todays' featured posts</h1>
<?php if (function_exists('rps_show')) echo rps_show(); ?>
</br>
<div id="primary">
<div id="content" role="main">
<?php if ( have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
Any ideas?
This is more of a php question than a WP question, but there’s a great function here that does what you’re looking for.
You can then call the function to wrap whatever you want like this:
I would actually recommend hiding it with CSS. This is much easier than adding the necessary PHP code.
You would do this by simply adding Media Queries to your stylesheet.
You could then add any additional CSS needed to make the mobile version look correct. More information on media queries can be found at:
wp_is_mobile()
would be your thing.