GeoDirectory Supportchange location – GeoDirectory Support https://wpgeodirectory.com/support/topic/change-location/feed Sat, 07 Jun 2025 11:19:31 +0000 http://bbpress.org/?v=2.5.14-6684 en-US https://wpgeodirectory.com/support/topic/change-location/#post-30477 <![CDATA[change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30477 Mon, 09 Feb 2015 21:21:23 +0000 Strong Coffee On your demo site you have an option to Change Location in your header that lets you select the country/region/city. How do you add that? Can it be added to the sidebar?

]]>
https://wpgeodirectory.com/support/topic/change-location/#post-30479 <![CDATA[Reply To: change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30479 Mon, 09 Feb 2015 21:25:44 +0000 Simone Hello, to enable the location switcher, first create a menu in Appearance/menu, then link it to GD going to Geodirectory/Design and in the navigation tab select your menu, and then go to the MultiLocation settings and rich the option where it says “Show location switcher in menu”

to add it in your sidebar, or wherever you want, you can insert this shortcode


[geodir_location_tab_switcher autoredirect="1"]

in a text widget

]]>
https://wpgeodirectory.com/support/topic/change-location/#post-30571 <![CDATA[Reply To: change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30571 Tue, 10 Feb 2015 16:49:47 +0000 Strong Coffee Is there a way to just show the city using the shortcode?

]]>
https://wpgeodirectory.com/support/topic/change-location/#post-30577 <![CDATA[Reply To: change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30577 Tue, 10 Feb 2015 17:23:44 +0000 Simone I believe you can use this in your template


$current_location = geodir_get_current_location();
echo $current_location ;

and it will show only the city, but this needs to be inserted inside a function or in the child theme

]]>
https://wpgeodirectory.com/support/topic/change-location/#post-30579 <![CDATA[Reply To: change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30579 Tue, 10 Feb 2015 17:50:06 +0000 Paolo or create a shortcode and use it anywhere by adding this in your active theme functions.php



// Add Shortcode
function gd_curr_loc_shortcode() {

	// get the location
	$current_location = geodir_get_current_location();
	// return the location
return $current_location ;

}
add_shortcode( 'gd_curr_location', 'gd_currlocation_shortcode' );

than use shortcode [gd_curr_location].

Haven’t tested so use with care…

Thx

]]>
https://wpgeodirectory.com/support/topic/change-location/#post-30596 <![CDATA[Reply To: change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30596 Tue, 10 Feb 2015 19:06:16 +0000 Strong Coffee Added the code to my child theme’s function.php file then added the shortcode to my sidebar widget and it just displays “[gd_curr_location]” in the sidebar.

]]>
https://wpgeodirectory.com/support/topic/change-location/#post-30597 <![CDATA[Reply To: change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30597 Tue, 10 Feb 2015 19:06:42 +0000 Strong Coffee https://wpgeodirectory.com/support/topic/change-location/#post-30602 <![CDATA[Reply To: change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30602 Tue, 10 Feb 2015 19:48:02 +0000 Paolo you need to make your widgets shortcode ready. In wordpress shortcode are ment to be used in content area of posts and pages.

Add this to your functions.php

add_filter('widget_text', 'do_shortcode');

Thx

]]>
https://wpgeodirectory.com/support/topic/change-location/#post-30620 <![CDATA[Reply To: change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30620 Tue, 10 Feb 2015 20:40:25 +0000 Strong Coffee Still get the shortcode displaying as text on the page. Here’s what I added to my functions.php file:

add_filter(‘widget_text’, ‘do_shortcode’);

// Apply filter
add_filter(‘body_class’, ‘gd_body_classes’);

function gd_body_classes($classes) {
if (geodir_is_geodir_page()) { $classes[] = ‘this_is_a_gd_page’;
return $classes;}
}

// Add Shortcode
function gd_curr_loc_shortcode() {

// get the location
$current_location = geodir_get_current_location();
// return the location
return $current_location ;

}
add_shortcode( ‘gd_curr_location’, ‘gd_currlocation_shortcode’ );

]]>
https://wpgeodirectory.com/support/topic/change-location/#post-30623 <![CDATA[Reply To: change location]]> https://wpgeodirectory.com/support/topic/change-location/#post-30623 Tue, 10 Feb 2015 21:06:41 +0000 Paolo There was an error in the code provided and actually there was a much easier way to do it:

add_shortcode( 'gd_curr_location', 'geodir_get_current_location' );

Than use [gd_curr_location] to call the shortcode.

However this will only show the location once a location has been set and without the Location Switcher you will never be able to set one…

Once you add the location switcher allowing users to set a location, that text widget will show the location name…

Thx

]]>