Get location list in Shortcode

Hi @fan297

Thank you for reaching out.

You can use the following custom code to create the shortcode ([directorist_single_locations]) –

add_shortcode('directorist_single_locations', function () {


	$term_list = [];
	$listing_id = get_the_ID();

	$locations = get_the_terms($listing_id, ATBDP_LOCATION);
	$directory_types = get_the_terms($listing_id, ATBDP_DIRECTORY_TYPE);

	if ($directory_types && count($directory_types) > 0) {
		$directory_type = $directory_types[0]->slug;

	if ($locations && count($locations) > 0) {
		foreach ($locations as $location) {
			$term_list[] = $location->slug;

	if (!empty($term_list) && count($term_list) > 0) {
		echo do_shortcode('[directorist_all_locations slug="' . implode(',', $term_list) . '" directory_type="' . $directory_type . '" view="grid"]');

	return ob_get_clean();

Then use the Custom Content field to display the shortcode. You must get something similar to this result >

Please let me know if you need further assistance.

Kind Regards


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer