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

  1. perryb
    Posted 4 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


  2. Ben Huson
    Plugin Author

    Posted 4 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
    Posted 4 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

  • WP Geo
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic