WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: WP Geo] Conditionally remove WP-Geo code from wp_head()

[Resolved] [Plugin: WP Geo] Conditionally remove WP-Geo code from wp_head()

  • I was wondering if there is a way to conditionally remove the WP Geo code from wp_head() using functions.php.

    I found the add_action in wp-geo.php:

    add_action( 'wp_head', array( $wpgeo, 'wp_head' ) );

    But I can’t seem to figure how to disable this using a remove_action

    http://wordpress.org/extend/plugins/wp-geo/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Ben Huson
    Participant

    @husobj

    This should work:

    global $wpgeo;
    remove_action( 'wp_head', array( $wpgeo, 'wp_head' ) );

    You might need to do that within an ‘init’ action to ensure you try to remove it after it has been added.

    Brilliant – this worked for me:

    add_action('template_redirect', 'remove_wp_geo_from_head');
    
    function remove_wp_geo_from_head() {
    
    	if ( !is_page( 'map' ) ) {
    
    		global $wpgeo;
    		remove_action( 'wp_head', array( $wpgeo, 'wp_head' ) ); 
    
    	}
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] [Plugin: WP Geo] Conditionally remove WP-Geo code from wp_head()’ is closed to new replies.