• 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

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Using add_action in function.php and limit to get_posts?’ is closed to new replies.