Title: combining conditionals
Last modified: August 21, 2016

---

# combining conditionals

 *  [earthjibber](https://wordpress.org/support/users/earthjibber/)
 * (@earthjibber)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/combining-conditionals/)
 * Hi
 * Is it possible to combine mobble conditionals with wp conditionals? For example,
   I want to do something like this:
 *     ```
       <?php if (is_page_template('template-name.php') || (!is_mobile() || (!is_tablet())) { ?>
        code here
       <?php } ?>
       ```
   
 * I tried using it and it didn’t work for me, is there a way to combine them?
 * thanks
 * [http://wordpress.org/extend/plugins/mobble/](http://wordpress.org/extend/plugins/mobble/)

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/combining-conditionals/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/combining-conditionals/page/2/?output_format=md)

 *  [inTOWN](https://wordpress.org/support/users/intown/)
 * (@intown)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920480)
 * Hi there, I have the same question…
    I used
 *     ```
       if (is_mobile()) { ... }
       else {... }
       ```
   
 * But I am getting double content
 *  Plugin Author [Scott (@scottsweb)](https://wordpress.org/support/users/scottsweb/)
 * (@scottsweb)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920481)
 * Hi
    [@intown](https://wordpress.org/support/users/intown/) Can you post your 
   full code here. I think these two problems might be unrelated.
 * In answer to [@earthjibber](https://wordpress.org/support/users/earthjibber/)–
   I think it is to do with the way your grouping your conditionals. Try one on 
   each line and see how that goes.
 *  [inTOWN](https://wordpress.org/support/users/intown/)
 * (@intown)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920482)
 * I had fixed the desktop problem, but still had the problem with iPad > i think
   is_mobile is also calling the iPad?
 *     ```
       <?php if (is_mobile()) {
                               $attr = array(
                               'title'	=> 'meer info over '.get_the_title(),
                               'width' => 390,
                               'height' => 'auto'
                           ); ?>
                       	<a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('medium', $attr); ?> <div class="clearer"></div></a>
                       <?php } ?>
   
                       <?php if (is_tablet()) {
                               $attr = array(
                               'title'	=> 'meer info over '.get_the_title(),
                               'width' => 187,
                               'height' => 256
                           ); ?>
                           <a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('small', $attr); ?> <div class="clearer"></div></a>
                       <?php } if ( !is_mobile() ) {
                               $attr = array(
                               'title'	=> 'meer info over '.get_the_title(),
                               'width' => 187,
                               'height' => 256
                           	); ?>
                           <a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('medium', $attr); ?> <div class="clearer"></div></a>
                   	 <?php } ?>
       ```
   
 *  Plugin Author [Scott (@scottsweb)](https://wordpress.org/support/users/scottsweb/)
 * (@scottsweb)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920483)
 * Try this:
 *     ```
       <?php if (is_mobile()) { ?>
       					<?php $attr = array(
                               'title'	=> 'meer info over '.get_the_title(),
                               'width' => 390,
                               'height' => 'auto'
                           ); ?>
                       	<a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('medium', $attr); ?> <div class="clearer"></div></a>
   
                       <?php } else if (is_tablet()) { ?>
       					<?php $attr = array(
                               'title'	=> 'meer info over '.get_the_title(),
                               'width' => 187,
                               'height' => 256
                           ); ?>
                           <a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('small', $attr); ?> <div class="clearer"></div></a>
                       <?php } else { ?>
       					<?php $attr = array(
                               'title'	=> 'meer info over '.get_the_title(),
                               'width' => 187,
                               'height' => 256
                           	); ?>
                           <a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('medium', $attr); ?> <div class="clearer"></div></a>
                   	 <?php } ?>
       ```
   
 *  [inTOWN](https://wordpress.org/support/users/intown/)
 * (@intown)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920484)
 * Thank works perfect, thank you scott… I had been a late night that I couldn’t
   get through the conditional… I am deeply ashamed but you saved me!
 *  Plugin Author [Scott (@scottsweb)](https://wordpress.org/support/users/scottsweb/)
 * (@scottsweb)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920485)
 * My pleasure & good luck with the website 🙂
 *  [solosails](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920487)
 *  [solosails](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920488)
 * Hi, is there a solution to the first question?
 * How do you add several conditions together?
 * Ie if is mobile device or tablet or … for example?
 * Many thanks. Andrew
 *  Plugin Author [Scott (@scottsweb)](https://wordpress.org/support/users/scottsweb/)
 * (@scottsweb)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920489)
 * Sure. You should be able to group conditionals like so:
 * `if (is_mobile() || is_tablet()) {`
 * If its not detecting your current device, it may be because the detection library
   needs updating. Give this early release a try: [https://github.com/scottsweb/mobble/archive/master.zip](https://github.com/scottsweb/mobble/archive/master.zip)
 * Let me know how you get on.
 *  [solosails](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920490)
 * Hi there,
 * Thanks. That was how I had it but it wasn’t working with the tablet I have (Asus
   Google Nexus 7 with Jelly bean OS)
 * I have tried your new library, but it still doesn’t seem to work. However, it
   does with my mobile (ios7)
 * Any ideas? Cheers, Andrew
 * I’m trying to get the ‘Ticker Tape’ Section of my website to not show on mobile
   and small screen devices as it scrolls the page down when it overflows.
 * [sailmakers](http://www.solosails.com)
 *  Plugin Author [Scott (@scottsweb)](https://wordpress.org/support/users/scottsweb/)
 * (@scottsweb)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920491)
 * There are a couple of potential problems.
 * 1. Make sure your website does not use caching – any caching that skips PHP will
   not work with mobble.
    2. Give one of these a try:
 * `is_handheld()` – to capture all handheld devices
    `is_mobile() || is_tablet()
   || is_android` – a tricky one as and you can also have Android based TVs these
   days – but it should work for the majority of use cases.
 *  [solosails](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920492)
 * Hmm, still not working.
 * I thought it was because I had an exclamation mark on the first like so…
 * if (!is_mobile() || is_tablet()) {
 * But if I take this away, it stops working with the mobile.
 * If I have t set as above, it works with the mobile, but not the tablet, if I 
   take the exclamation mark away it doesnt work with the mobile, if I keep the 
   exclamation mark and add any more that above it stops working with the mobile!…?
 *  [solosails](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920493)
 * Ok,
 * using just…
 *  if (!is_handheld()) {…}
 * seems to get it working on all devices. I guess I was having problems because
   I was trying to tell it NOT to do something, so that might change the way you
   list multiple conditions?
 * Thanks for your help, A
 *  Plugin Author [Scott (@scottsweb)](https://wordpress.org/support/users/scottsweb/)
 * (@scottsweb)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920494)
 * Excellent. There is also an `is_desktop()` function which you may find useful
   too.
 *  [solosails](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/#post-3920495)
 * Hi,
 * Yes, to work at it the other way around!
 * Many thanks, Andrew

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/combining-conditionals/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/combining-conditionals/page/2/?output_format=md)

The topic ‘combining conditionals’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/mobble_f5f5f5.svg)
 * [mobble](https://wordpress.org/plugins/mobble/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mobble/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mobble/)
 * [Active Topics](https://wordpress.org/support/plugin/mobble/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mobble/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mobble/reviews/)

## Tags

 * [conditionals](https://wordpress.org/support/topic-tag/conditionals/)

 * 17 replies
 * 5 participants
 * Last reply from: [Scott (@scottsweb)](https://wordpress.org/support/users/scottsweb/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/combining-conditionals/page/2/#post-3920497)
 * Status: not resolved