JANUARY SALE: Directory Theme Now Only $49 -- Learn More

Ask the community

This is a community support forum where you can ask
questions and interact with other PremiumPress Customers.

count listings… and display on text widget

  • Aaron
    Aaron
    Super Guru 922 points
    April 26, 2018 at 1:00 am

    This is built into wordpress i.e

    $count_posts = wp_count_posts( ‘listing_type’ )->publish;

    turn it into a shortcode:

    <?php
    // Display published Listings using the shortcode [published-listings]
    function wb_published_listings() {
        return wp_count_posts('listing_type')->publish;
    }
    add_shortcode('published-listings', 'wb_published_listings');
  • Jason
    Jason
    Guru 837 points
    April 26, 2018 at 1:30 am

    Am I adding that code above somewhere ?

    This returned

    http://prntscr.com/ja7moz

    http://prntscr.com/ja7mxe

  • Aaron
    Aaron
    Super Guru 922 points
    April 26, 2018 at 1:35 am

    I edited after I posted it – the post type should be “listing_type” not “post”:

    return wp_count_posts(‘listing_type’)->publish;

    This code below goes in your functions.php file:

    // Display published Listings using the shortcode [published-listings]
    function wb_published_listings() {
        return wp_count_posts('listing_type')->publish;
    }
    add_shortcode('published-listings', 'wb_published_listings');

    Mark has to fix this text-break in the forum lol.

  • Liz
    Liz
    Elite Member 442 points
    April 26, 2018 at 2:02 am

    Why is this post showing as recent post ……… ?
    Indicating @Aaron responded to this thread 22 mins ago.

    This post is Old from 2014 (February 25, 2014 at 9:01 pm)
    It is now 26th April 2018 ……

  • Aaron
    Aaron
    Super Guru 922 points
    April 26, 2018 at 2:11 am

    Why is this post showing as recent post ……… ?
    Indicating @Aaron responded to this thread 22 mins ago.

    It was updated on page 2 of this thread yesterday by a few users.

    Tested the code see attached pics:

    Attachments:
    You must be logged in to view attached files.
  • Aaron
    Aaron
    Super Guru 922 points
    April 26, 2018 at 2:12 am

    And the result:

    Attachments:
    You must be logged in to view attached files.
  • Jason
    Jason
    Guru 837 points
    April 26, 2018 at 2:22 am

    Aaron, Are the Australian buddy I spoke to on the phone in Sunny Queensland Australia, where all the Kangaroos, Koalas, Emus, Wallbies, Foxes & crazy wombats hang out ?

    About Liz, I wonder why she steps-in for no reason saying things like that, isnt facebook for that pmsl, lookin for a bone to pick with someone I guess.

    Anyways, Very good ole matey, that code above works good, time for a tiny lol

  • Aaron
    Aaron
    Super Guru 922 points
    April 26, 2018 at 2:37 am

    No probs :)

    Plugin version is attached.

    Display published Listings using the shortcode [published-listings]
    and Categories with [published-cats]

    Attachments:
    You must be logged in to view attached files.
  • Liz
    Liz
    Elite Member 442 points
    April 26, 2018 at 3:04 am

    no probs :) sorry I thought the forum was broken, I’ve been seeing a few very outdated posts lately at the top, seeing as no dates are shown in actual posts :)
    It’s all good :)


  • Janak
    Super Guru 1,283 points
    April 26, 2018 at 7:19 am

    26/4/18 – they need to fix this forum with the lack of dates, it’s ridiculous you only know the date of the last post and have no idea if the post before that it is a day old or 4 years old!
    How can people search the forum for meaningful information without dates on posts!

  • Ramon
    Ramon
    Senior Member 175 points
    April 26, 2018 at 7:46 am

    Yes, this text br
    eaking problem
    is not exactly th
    e best advertise
    ment for buddyp
    ress, is it?

Viewing 11 posts - 31 through 41 (of 41 total)