count listings… and display on text widget

WordPress Business Themes Forums Version 7 Themes DirectoryPress count listings… and display on text widget

count listings… and display on text widget

February 25, 2014
Rainer Rainer
  • Aaron
    Aaron
    Super Guru 916 points

    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');
    April 26, 2018 at 1:00 am
  • Jason
    Jason
    Titan 787 points

    Am I adding that code above somewhere ?

    This returned

    http://prntscr.com/ja7moz

    http://prntscr.com/ja7mxe

    April 26, 2018 at 1:30 am
  • Aaron
    Aaron
    Super Guru 916 points

    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.

    April 26, 2018 at 1:35 am
  • Liz
    Liz
    Elite Member 439 points

    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 ……

    April 26, 2018 at 2:02 am
  • Aaron
    Aaron
    Super Guru 916 points

    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.
    April 26, 2018 at 2:11 am
  • Aaron
    Aaron
    Super Guru 916 points

    And the result:

    Attachments:
    You must be logged in to view attached files.
    April 26, 2018 at 2:12 am
  • Jason
    Jason
    Titan 787 points

    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

    April 26, 2018 at 2:22 am
  • Aaron
    Aaron
    Super Guru 916 points

    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.
    April 26, 2018 at 2:37 am
  • Liz
    Liz
    Elite Member 439 points

    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 :)

    April 26, 2018 at 3:04 am

  • Janak
    Super Guru 1,284 points

    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!

    April 26, 2018 at 7:19 am
  • Ramon
    Ramon
    Senior Member 174 points

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

    April 26, 2018 at 7:46 am
Viewing 11 posts - 31 through 41 (of 41 total)

Didn't find what you were after?

Chat with us now

or contact our support team