Business Listings Counter
This topic contains 17 replies, has 3 voices, and was last updated by netbrasil 9 years, 4 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
May 5, 2016 at 7:49 am #184986
Hi, Is there a way to show somewhere in the site on how many listings we have already. ( E.g Business listings registered : 34 ). Do you know any extension or plugin that does this?
May 5, 2016 at 10:29 am #185000Hi there, you have to use the following code if you need listing count.
$query_args = array( 'post_type' => 'gd_place', ); echo geodir_get_widget_listings($query_args, true);May 5, 2016 at 11:49 pm #185405Thanks Tom!
May 6, 2016 at 2:18 am #185433Hi,
I have added this code in my functions.php
// Add number of listings function listing_count(){ $query_args = array( 'post_type' => 'gd_services', ); echo geodir_get_widget_listings($query_args, true); } add_shortcode('listingcount', 'listing_count');I’m no programmer but i hope i’m in the right track.
Anyway, the output is 0 even though i already have a bunch of listings in gd_services post type.
I want the total of all post types. How do we do that?
Cheers!
May 6, 2016 at 5:47 pm #185749Hi,
I asked to Giri to follow up. He’s off for the week end now, so he’ll reply on monday.
Thanks for your patience,
May 9, 2016 at 7:18 am #186991Hi there, You have almost made it work except that you are supposed to use return in shortcodes instead of echoing it.
Just place this code and let me know how that goes.
// Add number of listings function listing_count(){ $query_args = array( 'post_type' => 'gd_services', ); return geodir_get_widget_listings($query_args, true); } add_shortcode('listingcount', 'listing_count');May 9, 2016 at 7:20 am #186992If that doesn’t work make sure you are using the correct post type name.
It might be
gd_serviceinstead of
gd_servicesMay 10, 2016 at 6:33 am #187684Hi Tom,
Added your code and tried
gd_servicei’m still getting 0 as a result.
Also, i want the total of business listings of all posts types not just servicesHere’s a list of my post types
Thank you!
May 10, 2016 at 7:04 am #187698If you need ALL listing count, try this code
// Add number of listings function listing_count(){ $post_types = geodir_get_posttypes('Array'); $count = 0; if (!empty($post_types)) { foreach ($post_types as $post_type => $cpt_info) { $query_args = array( 'post_type' => $post_type, ); $output = geodir_get_widget_listings($query_args, true); $count = $count + (int) $output; } } return $count; } add_shortcode('listingcount', 'listing_count');May 11, 2016 at 12:42 am #188088Hi Ethan,
The shortcode output is still 0 🙂
May 11, 2016 at 7:47 am #188208Well, everytime I give you some code I test it in my local before post here. So I think you are doing it wrong.
Give me steps of what you have done, where do you use this shortcode, page url, login details etc to debug this issue.
Thanks
May 12, 2016 at 12:10 am #189082Hi,
I’m pasting the code in my functions.php which is located here /wp-content/themes/geodir_gdf-modern
then added the shortcode in my text widget : http://prntscr.com/b2zpx5 and this is the result : http://prntscr.com/b2zq1sMay 12, 2016 at 7:50 am #189256Shortcodes are not supported in widget by default.
Make sure you have this code in your child theme.
add_filter('widget_text', 'do_shortcode');If thats not working then i need your login details and ftp details
May 13, 2016 at 7:45 am #189793This reply has been marked as private.May 13, 2016 at 8:08 am #189796ok, I have fixed it. Looks like you don’t have any listings for that particular location. I have removed location filter. its showing count now.
Thanks
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket