Skip to content

How to display total number of ads in Classifieds website?

Displaying total number of ads will encourage site visitors to post their ads and will give some credibility to your classifieds website. Also this will work positive if you have more than 100 ads, other vise your site may give impression of dead website to new visitor.

In ClassiBase we have very flexible “Text” widget which can be regular text, JavaScript or PHP. For displaying total number of ads, ads posted last month and last day we will use PHP. Getting total number of ads in ClassiBase may be tricky for some users that is why we created this tutorial to give exact PHP code that you can use for your website.

PHP Widget to show total number of classified ads

Here is PHP code that will get number of ads total, last month and last day:

Total ads <b><?php echo Ad::countByClass('Ad', 'listed=?', array(1));?></b>, last month <b><?php echo Ad::countByClass('Ad', 'listed=? AND added_at>?', array(1,floor(REQUEST_TIME/3600)*3600-3600*24*30));?></b>, last day <b><?php echo Ad::countByClass('Ad', 'listed=? AND added_at>?', array(1,floor(REQUEST_TIME/3600)*3600-3600*24));?></b>

Paste it to your text widget and select text format as PHP as shown in image. Read more about using text widget for monetization with ads in detailed tutorial.

This code will display result like displayed below:

Total ads 3439, last month 865, last day 28

Display total number of ads with custom PHP code inside sidebar widget on classifieds website.

Display total number of ads with custom PHP code inside sidebar widget on classifieds website.

If you have multilingual classifieds website then remember pasting given text for all languages, otherwise it will not show for other languages.

We used Ad::countByClass('Ad', 'listed=?', array(1)); method to get total number of live ads.

For day and month totals we used floor(REQUEST_TIME/3600)*3600 to round time because Ad::countByClass method have built in caching feature which will use every parameter as cache key. So this will keep database queries to your server at minimum level by caching results.

Also you can style your code using HTML and CSS if you want total number of ads to catch attention of your visitors.

FAQ

Why to display total number of classified ads?

Total number of ads is a way of showing success of your classifieds website. More ads you have more successful your website become. If you have free classifieds website then having more than 10k ads can be considered as successful website. If you have only paid ads for example job listings for popular blog then 100 ads can be considered as successful website. In both cases it is good to show total number of ads.

  • Displaying 10k ad count for free classifieds website means your users will want to pay to make their ads featured.
  • Displaying 100 ads for not-free classifieds website means there are 100 people regularly paying for ads so it has a good conversion and worth paying to post ads there.

Total number of ads also encourages to post more ads on classifieds website.

When to display number of ads?

Display total number of classified ads only when it makes sense. remember this number should encourage people to take action. Either to post more ads, search for ads, post paid ads, make their ads featured.

How many ads are enough for classifieds website?

There is no upper limit for classifieds website. You can have as many ads as you want and it is always good when your website actively used. Remember you need to have unique and genuine ads in order to succeed. More ads you have more money you can earn. you may need to optimize your classified ads website if you rich more than 10k ads on shared server.

Success of classifieds website measured by money you are earning from it. So 100 paid ads is always good than having 10k free ads.

How to show number of ads in each category?

Total number of ads shows popularity of classifieds website. Number of ads in each category shows how popular each category. You can display number of ads in each category by using category widget. Same feature available for location widget as well. Check "Display ad count" checkbox in each widget where you want to display number of classified ads.

Display number of ads in each category/location on classifieds website with related widget.

Display number of ads in each category/location on classifieds website with related widget.

Read more about category and location widget options.

Conclusion on display number of classified ads

Total number of classified ads is decision making factor for your website. Depending on total number of ads it may encourage to post more ads, make more ads featured, search for more items. It is important that your visitors feel that website is active and used by many users. So they can invest their time and money to post more ads on your website.

We showed how to display total number of ads in classifieds website with custom PHP code in a test widget. You can further customize and add call to action text to it if you want.

Remember that every little detail added to your classifieds website should encourage your users to use your website more.