WordPress.org

Ready to get started?Download WordPress

Forums

WP Geo
[resolved] Conditionally remove WP-Geo code from wp_head() (3 posts)

  1. perryb
    Member
    Posted 2 years ago #

    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/

  2. Ben Huson
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  3. perryb
    Member
    Posted 2 years ago #

    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' ) ); 
    
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags