Ulisting Shortcodes

Below, you’ll find a detailed guide on how to add the Ulisting Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Ulisting Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Ulisting Plugin and the shortcodes it provides:

Plugin Icon
Directory Listings WordPress plugin – uListing

"uListing Directory Listings WordPress plugin is a robust solution for creating, managing, and monetizing an online directory site. Perfect for real estate, events, and more."

★★★★✩ (28) Active Installs: 3000+ Tested with: 6.1.4 PHP Version: false
Included Shortcodes:
  • [ulisting-comment]
  • [ulisting-user-comment]
  • [ulisting-feature]
  • [ulisting-category]
  • [ulisting-posts-view]
  • [ulisting-region-list]
  • [search-form-type]
  • [search-form-category]
  • [ulisting_account_panel]
  • [ulisting-pricing-plan]

Ulisting [ulisting-comment] Shortcode

The Ulisting Comment shortcode is a predefined command in WordPress that allows users to engage with your content. The shortcode_comment function in the PHP code loads the comment template from the Ulisting plugin, enabling users to leave comments on your listings. This feature enhances user interaction and engagement on your site.

Shortcode: [ulisting-comment]

Examples and Usage

Basic example – The shortcode can be used to load a comment template with specific parameters.

[ulisting-comment id="1" /]

Advanced examples

It’s possible to use the shortcode to load different comment templates by referencing both ID and some other parameters. The template will first try to load by ID, but if not found, it will try to load by other parameters.

[ulisting-comment id="1" type="review" status="approved" /]

Another advanced usage of the shortcode could be to load a comment template based on the user id. This can be useful when you want to display comments from a specific user.

[ulisting-comment user_id="2" /]

Lastly, you can also load a comment template based on a specific date. This can be useful when you want to display comments from a certain period.

[ulisting-comment date="2021-12-01" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [ulisting-comment] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ulisting-comment', [self::class, 'shortcode_comment']);

Shortcode PHP function:

                    function shortcode_comment($params){
		return StmListingTemplate::load_template( 'comment/comment', [ 'params' => $params ]);
	}
                    

Code file location:

ulisting/ulisting/includes/classes/StmComment.php

Ulisting [ulisting-user-comment] Shortcode

The Ulisting User Comment shortcode is used to add a user comment form to a webpage. It takes a user_id as a parameter and returns a comment form for the specified user. The PHP function checks if the user_id is set and valid. If not, it returns null. If valid, it loads a user comment template, passing the user object to it.

Shortcode: [ulisting-user-comment]

Parameters

Here is a list of all possible ulisting-user-comment shortcode parameters and attributes:

  • user_id – Identifier to specify the user for the comment form.

Examples and Usage

Basic example – The shortcode allows you to display user comments on your WordPress site. The user_id parameter is necessary to identify which user’s comments to display.

[ulisting-user-comment user_id=1 /]

Advanced examples

Using the shortcode to display comments from multiple users. Here, you would need to specify each user_id separately. This is a more advanced usage of the shortcode that allows you to display comments from multiple users at once.

[ulisting-user-comment user_id=1 /]
[ulisting-user-comment user_id=2 /]
[ulisting-user-comment user_id=3 /]

Note: The user_id parameter corresponds to the unique ID assigned to each user in your WordPress database.

PHP Function Code

In case you have difficulties debugging what causing issues with [ulisting-user-comment] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ulisting-user-comment', [self::class, 'shortcode_user_comment_form']);

Shortcode PHP function:

                    function shortcode_user_comment_form($params){
		if(!isset($params['user_id']) OR !($user = new \uListing\Classes\StmUser($params['user_id'])) )
			return null;
		return StmListingTemplate::load_template( 'comment/user-comment', [ 'user' => $user ]);
	}
                    

Code file location:

ulisting/ulisting/includes/classes/StmComment.php

Ulisting [ulisting-feature] Shortcode

The uListing Feature shortcode is used to display featured listings in a grid format on your WordPress site. This shortcode fetches listings based on the ‘listing_type_id’ parameter. If the listing type is found, it retrieves the featured listings up to the limit set in the ‘limit’ parameter. The listings are returned in a grid view, with each item styled as ‘ulisting-feature-item’.

Shortcode: [ulisting-feature]

Parameters

Here is a list of all possible ulisting-feature shortcode parameters and attributes:

  • limit – sets the maximum number of featured listings to display.
  • listing_type_id – specifies the type of listings to display based on their ID.

Examples and Usage

Basic example – The shortcode “ulisting-feature” is used to display a listing feature with a default limit of 5. The limit refers to the number of listing features to be displayed.

[ulisting-feature limit=3 /]

Advanced examples – In these examples, we are using the shortcode to display listing features by referencing both limit and listing_type_id. The listing_type_id is used to specify the type of listings to be displayed. The listing will first try to load by limit, but if not found, it will try to load by listing_type_id.

[ulisting-feature limit=3 listing_type_id=1 /]

Another advanced usage of the shortcode is to display listing features without specifying the limit. In this case, the default limit set in the plugin settings will be used.

[ulisting-feature listing_type_id=1 /]

It’s important to note that the shortcode only displays published listings. If a listing is not published, it won’t be displayed even if it matches the specified listing_type_id and limit.

PHP Function Code

In case you have difficulties debugging what causing issues with [ulisting-feature] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("ulisting-feature", [self::class, "ulisting_feature"]);

Shortcode PHP function:

                    function ulisting_feature($params)
    {
        $listings   = null;
        $view_type  = "grid";
        $item_class = "ulisting-feature-item";
        $limit      = (isset($params['limit'])) ? $params['limit'] : get_option("ulisting_feature_limit", 5);

        if (isset($params["listing_type_id"])) {
            $listing_type = StmListingType::find_one($params["listing_type_id"]);
            if ( !$listing_type ) {
                $args = array(
                    'meta_query' => array(
                        array(
                            'key' => "ulisting_import_id",
                            'value' => $params["listing_type_id"]
                        )
                    ),
                    'post_status' => 'publish',
                    'post_type' => 'listing_type',
                    'posts_per_page' => '1'
                );
                $posts = get_posts($args);

                if (isset($posts[0]) AND isset($posts[0]->ID) AND $listing_type = StmListingType::find_one($posts[0]->ID)) {
                    $listing_type = $listing_type->ID;
                }
            } else
                $listing_type = $listing_type->ID;


            $listings = StmListing::get_listing(['listing_type' => $listing_type, 'feature' => 1], $limit, 1);
            if (count($listings['models']) > 0)
                foreach ($listings['models'] as $model)
                    $model->featured = 1;
        }

        return StmListingTemplate::load_template(
            'listing/ulisting-feature',
            [
                "listings"      => is_null($listings) ? [] : $listings['models'],
                "view_type"     => $view_type,
                "item_class"    => $item_class,
            ]);
    }
                    

Code file location:

ulisting/ulisting/includes/classes/StmListing.php

Ulisting [ulisting-category] Shortcode

The Ulisting Category shortcode is designed to retrieve and display specific listings by category. It functions by accepting parameters for listing type and category. If the listing type is found, it fetches the associated listings. If not, it conducts a meta query. It then fetches the specified categories, maps them, and gets the listings for these categories. The output is a grid view of listing items.

Shortcode: [ulisting-category]

Parameters

Here is a list of all possible ulisting-category shortcode parameters and attributes:

  • listing_type_id – Identifier to select a specific type of listing
  • category – Defines the category of the listing
  • limit – Sets the maximum number of listings to display

Examples and Usage

Basic Example – Show a specific listing category by its ID

[ulisting-category listing_type_id=1 category="cars"]

This shortcode example will display a specific listing type with ID 1 and the category named “cars”.

Advanced Examples

Show a specific listing category by its ID and limit the number of listings shown

[ulisting-category listing_type_id=1 category="cars" limit=10]

This shortcode example will display a specific listing type with ID 1 and the category named “cars”, but it limits the number of listings shown to 10.

Show multiple categories

[ulisting-category listing_type_id=1 category="cars,bikes"]

This shortcode example will display a specific listing type with ID 1 and the categories “cars” and “bikes”. This is useful when you want to display listings from more than one category.

PHP Function Code

In case you have difficulties debugging what causing issues with [ulisting-category] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("ulisting-category", [self::class, "ulisting_category"]);

Shortcode PHP function:

                    function ulisting_category($params)
    {
        $listing_type = null;
        if (isset($params["listing_type_id"])) {
            $listing_type = StmListingType::find_one($params["listing_type_id"]);
            if (!($listing_type = StmListingType::find_one($params["listing_type_id"]))) {
                $args = array(
                    'meta_query' => array(
                        array(
                            'key' => "ulisting_import_id",
                            'value' => $params["listing_type_id"]
                        )
                    ),
                    'post_status' => 'any',
                    'post_type' => 'listing_type',
                    'posts_per_page' => '1'
                );
                $posts = get_posts($args);
                if (isset($posts[0]) AND isset($posts[0]->ID) AND $listing_type = StmListingType::find_one($posts[0]->ID)) {
                    $listing_type = $listing_type->ID;
                }
            } else
                $listing_type = $listing_type->ID;
        }

        $categories = explode(",", $params['category']);
        $categories = StmListingCategory::query()
            ->asTable('category')
            ->where_in("category.slug", $categories)
            ->find();
        $categories = ArrayHelper::map($categories, "term_id", "term_id");
        $sections = [];
        $view_type = "grid";
        $item_class = "ulisting-category-item";
        $limit = (isset($params['limit'])) ? $params['limit'] : get_option("ulisting_category_limit", 5);
        $page = (get_query_var(ulisting_page_endpoint())) ? get_query_var(ulisting_page_endpoint()) : 0;
        $listings = StmListing::get_listing(['listing_type' => $listing_type, 'category' => $categories], $limit, 1);
        return StmListingTemplate::load_template(
            'listing/ulisting-category',
            [
                "listings" => $listings['models'],
                "view_type" => $view_type,
                "item_class" => $item_class,
            ]);
    }
                    

Code file location:

ulisting/ulisting/includes/classes/StmListing.php

Ulisting [ulisting-posts-view] Shortcode

The uListing Posts View shortcode is a powerful tool that dynamically fetches and displays posts based on specific parameters. It retrieves post settings from the meta data, identifies the view type, and checks for the listing type. If the listing type is set, it retrieves the corresponding post. If not, it runs a query to find the post with the matching ID. It then returns a template loaded with the fetched data, ready for display.

Shortcode: [ulisting-posts-view]

Parameters

Here is a list of all possible ulisting-posts-view shortcode parameters and attributes:

  • type_id – The unique identifier of the listing type

Examples and Usage

Basic example – Displaying a specific post view based on the type ID.

[ulisting-posts-view type_id=1 /]

Advanced examples

Using the shortcode to display a specific post view by referencing the type ID. If the listing type is not found by the given type ID, it will try to load the listing type by the post’s ID.

[ulisting-posts-view type_id=2 /]

In this example, the shortcode is trying to fetch and display the post view of a listing type with the type ID 2. If the listing type is not found by the given type ID, it will try to load the listing type by the post’s ID. This is a more advanced usage of the shortcode as it is using a different parameter (type_id=2) compared to the basic example.

PHP Function Code

In case you have difficulties debugging what causing issues with [ulisting-posts-view] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('ulisting-posts-view', array(self::class, 'ulisting_posts_view'));

Shortcode PHP function:

                    function ulisting_posts_view($params)
    {
        $type_id = intval($params['type_id']);
        $settings = get_post_meta($type_id, 'listing_post_settings');

        $settings = $settings[0];
        $view = $settings['listing_posts_view'];

        $listingType = null;
        if(isset($settings['listing_posts_type_list'])){
            $listingType = \uListing\Classes\StmListingType::find_one($type_id);
            if( !($listingType = \uListing\Classes\StmListingType::find_one($type_id)) ) {
                $args = array(
                    'meta_query'        => array(
                        array(
                            'key'       => "ulisting_import_id",
                            'value'     => $type_id
                        )
                    ),
                    'post_status'       => 'any',
                    'post_type'         => 'listing_type',
                    'posts_per_page'    => '1'
                );
                $posts = get_posts( $args );
                if(isset($posts[0]) AND isset($posts[0]->ID)){
                    $listingType = \uListing\Classes\StmListingType::find_one($posts[0]->ID);
                }
            }
        }

        return StmListingTemplate::load_template(
            'listing-posts/listing-posts',
            array(
                'view' => $view,
                'type_id' => $type_id,
                'settings' => $settings,
                'listingType' => $listingType,
            )
        );
    }
                    

Code file location:

ulisting/ulisting/includes/classes/StmListing.php

Ulisting [ulisting-region-list] Shortcode

The Ulisting Region List shortcode is designed to fetch and display a list of regions from your listings. It allows you to specify regions and listing type ID as parameters. This shortcode queries the database for specific regions associated with a certain listing type. If the data isn’t in the cache, it fetches it from the database, then caches it for 24 hours. The data includes the count of items, maximum and minimum price for each region.

Shortcode: [ulisting-region-list]

Parameters

Here is a list of all possible ulisting-region-list shortcode parameters and attributes:

  • regions – List of region IDs to display in the list
  • listing_type_id – ID of the listing type to filter the region list

Examples and Usage

Basic example – Display a list of regions using the shortcode. Here, we are not specifying any parameters, so the shortcode will return all regions.

[ulisting-region-list /]

Advanced examples

Display a list of specific regions by providing their IDs. The regions parameter accepts a comma-separated list of region IDs. In this example, we are displaying regions with IDs 1, 2, and 3.

[ulisting-region-list regions="1,2,3" /]

Filter the region list based on the listing type. The listing_type_id parameter accepts the ID of a listing type. In this example, we are displaying regions associated with the listing type with ID 5.

[ulisting-region-list listing_type_id="5" /]

Combine both parameters to display a list of specific regions associated with a specific listing type. In this example, we are displaying regions with IDs 1, 2, and 3 that are associated with the listing type with ID 5.

[ulisting-region-list regions="1,2,3" listing_type_id="5" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [ulisting-region-list] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("ulisting-region-list", [self::class, 'region_list_short_code']);

Shortcode PHP function:

                    function region_list_short_code($params){
		global $wpdb;
		$regions      = [];
		$listing_type_id = 0;
		$listing_type = 0;

		if(isset($params["regions"]) AND !empty($params["regions"]))
			$regions = explode(",", $params["regions"]);

		if(isset($params["listing_type_id"]) AND !empty($params["listing_type_id"])){
			$listing_type_id = (int)sanitize_text_field($params["listing_type_id"]);
			if( ! ($listing_type = StmListingType::find_one($listing_type_id)) ) {
				$args = array(
					'meta_query'        => array(
						array(
							'key'       => "ulisting_import_id",
							'value'     => $listing_type_id
						)
					),
					'post_status'       => 'any',
					'post_type'         => 'listing_type',
					'posts_per_page'    => '1'
				);
				$posts = get_posts( $args );
				if(isset($posts[0]) AND isset($posts[0]->ID) AND $listing_type = StmListingType::find_one($posts[0]->ID)){
					$listing_type_id = $listing_type->ID;
				}
			}
		}

        $data = get_transient("ulisting_region_list_short_code");
		$models  = StmListingRegion::query()
		                           ->where_in("term_id", $regions)
		                           ->find();

		if( empty($data) || !is_array($data) ) {
			$_models  = StmListingRegion::query()
                        ->asTable("region")
                        ->select(" region.`term_id`, region.`name`, MAX(Convert( listing_attribute_relation.`value` , SIGNED)) as max_price, MIN(Convert( listing_attribute_relation.`value` , SIGNED)) as min_price , COUNT(listing.ID) as items_count \n")
                        ->join(" left join `".$wpdb->prefix."term_taxonomy` as taxonomy on taxonomy.`term_id` = region.`term_id` \n")
                        ->join(" left join `".$wpdb->prefix."term_relationships` as term_relation on term_relation.`term_taxonomy_id` = taxonomy.`term_taxonomy_id` \n")
                        ->join(" left join `".$wpdb->prefix."posts` as listing on listing.ID = term_relation.`object_id` AND listing.`post_type` = 'listing' \n")
                        ->join(" left join `".$wpdb->prefix."ulisting_listing_type_relationships` as listing_type_relation on listing_type_relation.`listing_id` = listing.ID \n")
                        ->join(" left join `".$wpdb->prefix."posts` as listing_type on listing_type.ID = listing_type_relation.`listing_type_id` AND listing_type.`post_type` = 'listing_type' \n")
                        ->join(" left join `".$wpdb->prefix."ulisting_listing_attribute_relationships` as listing_attribute_relation on listing_attribute_relation.`listing_id` = listing.ID AND listing_attribute_relation.`attribute` = 'price' \n")
                        ->where("taxonomy.`taxonomy`", "listing-region")
                        ->where("listing_type.ID", $listing_type_id)
                        ->where_in("region.`term_id`", $regions)
                        ->group_by("region.term_id")
                        ->find();

			foreach ($_models as $model){
				$data[$model->term_id] = [
					'items_count' => $model->items_count,
					'max_price' => $model->max_price,
					'min_price' => $model->min_price
				];
			}
			set_transient("ulisting_region_list_short_code", $data, 24 * HOUR_IN_SECONDS);
		}
		return StmListingTemplate::load_template( 'region/region-list-short-code', [ "models" => $models, "data" => $data,  "params" => $params, "listing_type" => $listing_type ]);
	}
                    

Code file location:

ulisting/ulisting/includes/classes/StmListingRegion.php

Ulisting [search-form-type] Shortcode

The Ulisting Plugin shortcode ‘search-form-type’ is designed to display a search form based on specific listing types. It fetches the listing types that use a particular search form and displays them. The PHP function ‘search_form_type’ queries the database for listings with a status of ‘publish’ and a meta value of 1 for ‘use_search_form_type’. It also accommodates multilingual sites.

Shortcode: [search-form-type]

Examples and Usage

Basic example – The basic usage of the ‘search-form-type’ shortcode requires no explicit parameters. It will display the search form type for all published listing types that have the ‘use_search_form_type’ meta key set to 1.

[search-form-type /]

PHP Function Code

In case you have difficulties debugging what causing issues with [search-form-type] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('search-form-type', array(self::class, 'search_form_type'));

Shortcode PHP function:

                    function search_form_type($params = null)
    {
        global $wpdb;
        $lang = apply_filters('wpml_current_language', NULL);

        if (empty(ULISTING_DEFAULT_LANG)) {
            $listingsTypes = StmListingType::query()
                ->asTable("listing_type")
                ->join(" left join " . $wpdb->prefix . "postmeta as mete on mete.`post_id` = listing_type.ID AND mete.`meta_key` = 'use_search_form_type' ")
                ->where("listing_type.`post_status`", "publish")
                ->where("post_type", "listing_type")
                ->where("mete.`meta_value`", 1)
                ->find();
        } else {

            $listingsTypes = StmListingType::query()
                ->asTable("listing_type")
                ->join(" left join " . $wpdb->prefix . "postmeta as mete on mete.`post_id` = listing_type.ID AND mete.`meta_key` = 'use_search_form_type' ")
                ->join(" left join " . $wpdb->prefix . "icl_translations as translation on listing_type.ID = translation.`element_id`")
                ->where("listing_type.`post_status`", "publish")
                ->where("post_type", "listing_type")
                ->where("translation.language_code", $lang)
                ->where("mete.`meta_value`", 1)
                ->find();
        }
        return StmListingTemplate::load_template('filter/stm_search_form_type', array('listingsTypes' => $listingsTypes, 'params' => $params));
    }
                    

Code file location:

ulisting/ulisting/includes/classes/StmListingType.php

Ulisting [search-form-category] Shortcode

The Ulisting Search Form Category shortcode is designed to fetch and display listing categories. It’s primarily used to filter listings based on categories. This shortcode fetches categories based on the current language. If no default language is set, it retrieves all categories. It then fetches all published listing types. The results are passed into a template to generate the search form.

Shortcode: [search-form-category]

Examples and Usage

Basic example – The following example demonstrates the basic usage of the ‘search-form-category’ shortcode. It does not require any parameters, and when inserted, it will display a search form with categories.

[search-form-category /]

Advanced examples

The ‘search-form-category’ shortcode can also accept different parameters to customize the functionality. Below are some advanced examples:

Example 1: In this example, we are passing a ‘lang’ parameter to the shortcode. This will display the search form with categories in a specific language. Replace ‘en’ with your desired language code.

[search-form-category lang='en' /]

Example 2: In this example, we are passing a ‘post_status’ parameter to the shortcode. This will display the search form with categories from listings that have a specific post status. Replace ‘publish’ with your desired post status.

[search-form-category post_status='publish' /]

Example 3: In this example, we are passing two parameters ‘lang’ and ‘post_status’ to the shortcode. This will display the search form with categories from listings that have a specific post status and in a specific language. Replace ‘en’ and ‘publish’ with your desired language code and post status.

[search-form-category lang='en' post_status='publish' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [search-form-category] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('search-form-category', array(self::class, 'search_form_category'));

Shortcode PHP function:

                    function search_form_category($params = null) {
        global $wpdb;
        $lang = apply_filters('wpml_current_language', NULL);


        if (empty(ULISTING_DEFAULT_LANG)) {
            $categories = StmListingCategory::query()
                ->asTable('category')
                ->join(" left join " . $wpdb->prefix . "term_taxonomy as taxonomy on taxonomy.`term_id` = category.`term_id` ")
                ->where("taxonomy.taxonomy", "listing-category")
                ->find();;
        } else {

            $categories = StmListingCategory::query()
                ->asTable('category')
                ->join(" left join " . $wpdb->prefix . "term_taxonomy as taxonomy on taxonomy.`term_id` = category.`term_id` ")
                ->join(" left join " . $wpdb->prefix . "icl_translations as translation on category.`term_id` = translation.`element_id`")
                ->where("taxonomy.taxonomy", "listing-category")
                ->where("translation.language_code", $lang)
                ->find();

        }

        $listingsTypes = StmListingType::query()
            ->asTable("listing_type")
            ->where("listing_type.`post_status`", "publish")
            ->where("post_type", "listing_type")
            ->find();

        return StmListingTemplate::load_template(
            'filter/stm_search_form_category',
            array(
                'listingsTypes' => $listingsTypes,
                'categories' => $categories,
                'params' => $params
            )
        );
    }
                    

Code file location:

ulisting/ulisting/includes/classes/StmListingType.php

Ulisting [ulisting_account_panel] Shortcode

The Ulisting Account Panel shortcode is a useful tool for user management. It fetches the current user’s data and loads the account panel template. This shortcode enables the display of the user’s account panel on the front-end. It’s useful in creating a personalized user experience.

Shortcode: [ulisting_account_panel]

Examples and Usage

Basic example – Utilize the uListing account panel shortcode to display the current user’s account panel. This basic usage doesn’t require any additional parameters.

[ulisting_account_panel]

Advanced examples

Display the account panel for a specific user by passing the user’s ID as a parameter. This can be useful for admin users who need to view and manage different user accounts.

[ulisting_account_panel id=2]

Another advanced usage could be to pass multiple parameters to the shortcode. For instance, you can pass both the user ID and a ‘view’ parameter, which could determine the specific section of the account panel to display (e.g., ‘listings’, ‘favorites’, ‘settings’).

[ulisting_account_panel id=2 view='favorites']

Please note that the actual usage and available parameters may vary depending on the implementation of the ‘account_panel’ function in your uListing plugin.

PHP Function Code

In case you have difficulties debugging what causing issues with [ulisting_account_panel] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ulisting_account_panel', [self::class, "account_panel"] );

Shortcode PHP function:

                    function account_panel($params) {
		$user = new StmUser(get_current_user_id());
		StmListingTemplate::load_template('account/account-panel' , ['user' => $user, "params" => $params], !is_admin());
	}
                    

Code file location:

ulisting/ulisting/includes/classes/StmUser.php

Ulisting [ulisting-pricing-plan] Shortcode

The Ulisting Pricing Plan shortcode is designed to display various subscription plans on your website. It’s activated when the Ulisting subscription is active. This shortcode fetches all the pricing plans, checks if the Ulisting subscription is active, and if so, retrieves all the subscription plans. It then returns these plans within a div element with the id “stm-pricing-plan”.

Shortcode: [ulisting-pricing-plan]

Examples and Usage

Basic example – The uListing Pricing Plan shortcode displays the pricing plans available on your website. It does not require any parameters to function.

[ulisting-pricing-plan /]

PHP Function Code

In case you have difficulties debugging what causing issues with [ulisting-pricing-plan] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("ulisting-pricing-plan", [self::class, "pricing_plan_module"]);

Shortcode PHP function:

                    function pricing_plan_module($params) {
        $subscription_plans = [];
        $plans = self::get_pricing_plans();
        if ( ulisting_subscription_active() ) {
            $subscription_plans = self::get_subscription_plans();
        }

        return '<div id="stm-pricing-plan">' . StmListingTemplate::load_template('pricing-plan/list', [
                'plans' => $plans,
                'subscription_plans' => $subscription_plans
            ]) . '</div>';
    }
                    

Code file location:

ulisting/ulisting/includes/lib/pricing-plan/includes/classes/StmPricingPlans.php

Conclusion

Now that you’ve learned how to embed the Ulisting Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *