• In functions.php

    function map_header() {
    echo ‘<script type=”text/javascript” src=”‘.get_bloginfo(‘stylesheet_directory’).’/js/gmap.js”></script>’;
    echo ‘<script type=”text/javascript” src=”https://maps.google.com/maps/api/js?sensor=false”></script>&#8217;;
    }
    function map() {
    echo ‘some html’;
    add_action(‘wp_head’, ‘map_header’);
    }
    register_sidebar_widget(‘A map’, ‘map’);

    How come this doesn’t work? It works when I place add_action outside of map() – but that’s not what I want. I only want to add the javascript if the widgets is being used.

    Thank you

  • The topic ‘Problem with add_action, it doesn’t execute’ is closed to new replies.