• So this is what I currently have, if you will check to make sure I wrote this right. I am very green when it comes to this kind of stuff so i’m trying to teach myself.

    What I am trying to do is have the page refer to a different style mobile sheet depending on a phrase that is held within the post title in wordpress.

    <link type=”text/css” rel=”stylesheet” href=”<?php $string = get_the_title($post->post_parent); $pos = strpos($string, “ABCDEF”); if ($pos === false) {(‘/example1.css’);} else { (‘/example2.css’);} ?>” media=”screen and (max-width: 480px)” />

    So on another site I currently use the strpos command to grab a different header based on the content of the post title.
    <?php
    $string = get_the_title($post->post_parent);
    $pos = strpos($string, “AMI1”);
    if ($pos === false) {
    get_header(‘mlm’);
    } else {
    get_header(‘ami’);
    }
    ?>

    I then looked online and found the code that is used to grab the media=….max with… command. So I am trying to combine them

    <link type=”text/css” rel=”stylesheet” href=”https://dropship.com/sites/default/files/css/css_Hxnin-1SwvPu5El9PvnjYBVkWyIbBguo_VBqCEb8zRc.css&#8221; media=”screen and (max-width: 480px)” />

    I know that they both work separately, however i’m just taking a stab in the dark when it comes to combining them.
    So hopefully combining the two together should grab a separate style sheet for the mobile view based on a phrase that is held in the title.

    So if the title contains “abcdef” then it will display the /example1.css on the mobile device.

    If it doesn’t contain “abcdef” then it will display the /example2.css on the mobile device.

    Can anyone check to make sure I am doing it right and have the right characters in the right place?

    Thanks for taking a look at this for me!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter hudson4866

    (@hudson4866)

    To clarify this is the new code that I am trying to write:

    <link type=”text/css” rel=”stylesheet” href=”<?php $string = get_the_title($post->post_parent); $pos = strpos($string, “ABCDEF”); if ($pos === false) {(‘/example1.css’);} else { (‘/example2.css’);} ?>” media=”screen and (max-width: 480px)” />

    I will place this in my <head> section to call upon the mobile device.

    Did this work out for you? I’m looking into adding a mobile stylesheet, as well, and would like to know if you have any further tips.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different mobile style sheet depending on string in title’ is closed to new replies.