Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Minni

    (@minni)

    When I put the function isMobile() above the function mobil_styles_method() in functions.php there´s no error statement. The error starts later with

    add_action(‘wp_enqueue_scripts’,’mobil_styles_method’);
    Fatal error: Call to undefined function add_action()

    I have to say that in my mobile.css (see the function theme_styles) the sidebar appears at the bottom of the page and in the function mobil_styles_method() the sidebar should be hidden.

    But I don´t think that this conflict is the problem, it should be something else?!

    Thread Starter Minni

    (@minni)

    Hello again, yes you are right. I am using WordPress 3.5.2.

    Thread Starter Minni

    (@minni)

    Hallo, thanks for your attention. You´re right, of course. I put the code in the functions.php, not the header.php. It was a misunderstanding…

    Thread Starter Minni

    (@minni)

    Hello again,

    I tried the following code in my header.php of my child-theme:

    <?php
    function theme_styles()
    {
      wp_register_style( 'mobile-style', get_template_directory_uri() . '/mm-child/mobilestyle.css',array(),'','all');
    
      wp_enqueue_style('mobile-style');
    } 
    
    function costum_style()
    {
      wp_register_style( 'costum-style', get_template_directory_uri() . '/mm-child/style.css',array(),'','all');
    
      wp_enqueue_style('costum-style');
    } 
    
    function mobil_styles_method()
    {
      wp_enqueue_style('custom-style', get_template_dirrectory_uri() . '/mm-child/style.css');
        $mobilestyle = "
                      #page {
    	                 width: 480px;
    	                 display: inline;
    	                 float: left;
    	                 margin-left: 1%;
    	                 margin-right: 0;
    	                 position: relative;
                       }
    
                      #sidebar   {
                        display: no;
                        }
    
                      #footer-bar {
                        width: 480px;
                        background-color: yellow;
                      }";
        wp_add_inline_style( 'costum-style', $mobilestyle_css );
    }
    
    add_action('wp_enqueue_scripts','mobil_styles_method'); #LINE 41
    
    function isMobile()
    {
      return preg_match("/(android|avantgo|blackberry|mini|mobi|palm|phone|pie|tablet|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
    }
    if(isMobile())
    {
    add_action('wp_enqueue_scripts','theme_styles');
    }
    ?>

    [Please post code or markup between backticks or use the code button. Or better still – use a pastebin. Your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

    I thought one of these functions should work but it doesn´t.
    The only response when I put the path to my directory in the browser is:
    Fatal error: Call to undefined function add_action() in /www/htdocs/w00cefc0/wp-content/themes/mm-child/functions.php on line 41 (see above)

    I looked here:
    http://codex.wordpress.org/Function_Reference/add_action
    http://codex.wordpress.org/Function_Reference/wp_add_inline_style

    What I am doing wrong, who knows?

    Thank you for helping me.

    Thread Starter Minni

    (@minni)

    Hello again,

    thanks for your reply.

    I costumized the id´s of my own css in the text above.

    I don´t know how to create a plugin because I have only rudimentary knowledge of php. But I followed your link and built the following code in a functions.php in my child-theme:

    <?php
    function theme_styles()
    {
      wp_register_style( 'mobile-style', get_template_directory_uri() . '/mm/mobilestyle.css',array(),'','handheld'); 
    
      wp_enqueue_style('mobile-style');
    }
    add_action('wp_enqueue_scripts','theme_styles');
    
    #print "
    <pre>";
    #print_r($wp_styles);
    #print "</pre>
    <pre>";
    
    #mm is the directory of my parent-theme, I also tried it with mm-child
    ?>

    Nothing happens?! Not even a error?!

    Does anyone know what´s going on?

    Thread Starter Minni

    (@minni)

    Hello…

    Unfortunately I had no progress…

    Again I tried <link rel=”Stylesheet” type=”text/css” media=”handheld,screen and (max-width: 480px)” href=”<?php echo get_stylesheet_directory_uri(); ?>/mobile.css” /> in the <head> of my header.php, without success.

    I looked at the twentytwelve-theme (line 1586) and put at the end of my style.css :

    @media screen and (max-width: 480px) {

    #page {
    width: 480px;
    display: inline;
    float: left;
    margin-left: 1%;
    margin-right: 0;
    position: relative;
    }
    #sidebar {
    display: no;
    }
    #footer-bar {
    width: 480px;
    }
    }

    but nothing worked. Most www pages recommend @media

    There must be a possibility to use responsive design on wordpress sites without using any special (blank)theme!?

    Maybe a function that I can put in my child-theme is the solution?

    I can´t believe that it is so difficult to make use a separate .css-stylesheet in dependance of a (mobile) browser.

    How knows it?

    Thanks again.

    Thread Starter Minni

    (@minni)

    Hallo again,

    thank you very much for your help. I´ll have a look at it and try apply it to my site.

    Hopefully I will find a solution.

    Greetings

    Thread Starter Minni

    (@minni)

    Hello WPyogi,

    thanks for your reply. I´ve built a tiny site available on http://www.markusminning.de.

    It´s just to learn WP, before implementing it, my site was just html-based. I wanted to integrate a blog and use the same style/ appearance.

    Now I want to learn how to customize the site for mobile devices
    and studied through the fist twenty google result pages… Nothing worked.

    Do I need a function, a simple link to my mobile.css or how can I fix the problem? Do you know it?

    Thanks a lot and have a nice day! Markus

Viewing 8 replies - 1 through 8 (of 8 total)