Skip to content

Commit

Permalink
adding services count shortcode
Browse files Browse the repository at this point in the history
  • Loading branch information
jagdish1o1 committed Jul 17, 2024
1 parent bc41228 commit b92773e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 10 additions & 1 deletion includes/class-lgp-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ public function register()
{
add_shortcode('all_states', array($this, 'all_states_callback'));
add_shortcode('all_cities', array($this, 'all_cities_callback'));
add_shortcode('service_providers_list', array($this, 'service_providers_list_callback'));
add_shortcode('city_search', array($this, 'city_search_callback'));
add_shortcode('service_providers_list', array($this, 'service_providers_list_callback'));
add_shortcode('total_service_providers', array($this, 'total_service_providers_callback'));
add_action('wp_enqueue_scripts', array($this, 'custom_css_for_listings'));

}
Expand Down Expand Up @@ -127,6 +128,14 @@ public function city_search_callback($atts)

}

public function total_service_providers_callback() {
if (is_singular('listings')) {
$post_id = get_the_ID();
$service_providers = get_field('service_providers', $post_id);
return strval(count($service_providers));
}
}

public function custom_css_for_listings()
{

Expand Down
8 changes: 0 additions & 8 deletions includes/class-listings-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public function register()
// URL rewriting Rules
add_filter('post_type_link', array($this, 'listings_post_type_link'), 10, 2);
add_filter('rewrite_rules_array', array($this, 'custom_rewrite_rules'));
// add_action('save_post_listings', array($this, 'auto_generate_custom_uri'), 10, 3);
add_action('save_post_listings', array($this, 'flush_permalinks_on_save'), 10, 3);

}
Expand Down Expand Up @@ -76,13 +75,6 @@ public function register_fields()

}

public function get_acf_fields($object)
{
$fields = get_fields($object['id']);
return !empty($fields) ? $fields : [];
}


public function listings_post_type_link($post_link, $post)
{
if ('listings' === $post->post_type) {
Expand Down
2 changes: 1 addition & 1 deletion wp-leadgen-pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: WP Leadgen Pro
* Description: Plugin to integration with wp leadgen pro platform.
* Version: 1.0.3
* Version: 1.0.4
* Author: WP Leadgen Pro
* Author URI: https://wpleadgen.pro
* License: GPLv2 or later
Expand Down

0 comments on commit b92773e

Please sign in to comment.