PHP Notices / Shortcode Question (5 posts)

  1. Philip Arthur Moore
    Posted 4 years ago #

    Hi All.

    Two issues:

    1. When Geolocation is activated and a new Post is published without setting my location, I receive the following PHP notices:

    Notice: Undefined offset: 0 in /var/www/vhosts/server.com/sites/domainname.com/wp-content/plugins/geolocation/geolocation.php on line 537
    Notice: Undefined offset: 0 in /var/www/vhosts/server.com/sites/domainname.com/wp-content/plugins/geolocation/geolocation.php on line 537
    Notice: Undefined variable: city in /var/www/vhosts/server.com/sites/domainname.com/wp-content/plugins/geolocation/geolocation.php on line 522
    Notice: Undefined variable: city in /var/www/vhosts/server.com/sites/domainname.com/wp-content/plugins/geolocation/geolocation.php on line 524
    Notice: Undefined variable: state in /var/www/vhosts/server.com/sites/domainname.com/wp-content/plugins/geolocation/geolocation.php on line 526
    Notice: Undefined variable: country in /var/www/vhosts/server.com/sites/domainname.com/wp-content/plugins/geolocation/geolocation.php on line 528
    Notice: Undefined variable: address in /var/www/vhosts/server.com/sites/domainname.com/wp-content/plugins/geolocation/geolocation.php on line 531

    2. Is there any way to execute [geolocation] from my theme's functions.php file? When I try to run echo do_shortcode('[geolocation]'); in my theme's functions.php file nothing happens and the plain text "[geolocation]" is output to the browser. If this won't work, is there a way to change add_filter('the_content', 'display_location', 5); (located on line 31 of geolocation.php) without actually touching the plugin? I'd rather not package the plugin with my theme but I feel somewhat limited by the placement locations I'm offered. Thanks a lot.


  2. ajohnson
    Posted 4 years ago #

    having same issue of shortcode not running with do_shortcode code.

  3. Erik Rubright
    Posted 3 years ago #

    I had the same issue, this corrected it for me

    if (function_exists('display_location')){
    	echo display_location("[geolocation]");
    } ?>
  4. silvasonic
    Posted 3 years ago #

    I've tried the default <?php echo do_shortcode("[example_shortcode]"); ?> to no avail as well (sorry, I'm new to WP and PHP).

    I'm now using Erik's suggestion and the link + map show up where I place the code, but I was wondering if there was a way to encapsulate it in <li> tags for instance.

    Should I just concatenate it? Something like echo '<li>' . display_location("[geolocation]") '</li>' . '\n';

    Would that work?

  5. silvasonic
    Posted 3 years ago #

    I've just gone ahead and added the tags within the plug-in's code itself. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Geolocation
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic